Demo entry 6314832

test

   

Submitted by anonymous on Oct 31, 2016 at 16:55
Language: C. Code size: 574 Bytes.

#include <stdio.h>
#include <math.h>

int main()
{
	int m1 = 1, m2 = 2;
	int c1 = 28, c2 = 71;
	int k0 = 87;
	float N = 0, k1 = 0;
	printf("m1 = %d, m2 = %d,\nc1 = %d, c2 = %d,\nk0 = %d", m1, m2, c1, c2, k0);
	printf("\n\n  N  k1\n");
	for (int n1 = 0; n1<10; ++n1) {
		for (int n2 = 0; n2<10; ++n2) {
			N = (float)(m1 * (c1 - c2) - c1 * (m1 - m2) + k0 * (m1 - m2)) / (n1	* (m1 - m2) - m1 * (n1 - n2));
			k1 = (float)(n1 * N + c1 - k0) / m1;
			if (N > 0 && (floor(N) == N) && N < 128 && k1 <128)
				printf("%3.f %3.f\n", N, k1);
		}
	}
	return 0;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).