summaryrefslogblamecommitdiffstats
path: root/mat/advent/2/prog.c
blob: 663fe8f0d243877d9afc3817e7768689eb19c11d (plain) (tree)
























                                                                                                                                                                                                                                                                  
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char ** argv) {
	if (argc != 1+11) {
		fprintf(stderr, "uporaba: %s <stevilka> (=) <stevilka>(x) (+) <stevilka>(y) (+) <stevilka>(z) (;) <stevilka> (=) <stevilka>(x) (+) <stevilka>(y) (+) <stevilka>(z) <min> <max> <step>\nprimer: %s 53 3 2 5 91 5 3 9 0 100 1\n", argv[0], argv[0]);
		return 1;
	}
	unsigned int i;
	double j[3];
	double n[8];
	double min = atoi(argv[9]);
	double max = atoi(argv[10]);
	double step = atoi(argv[11]);
	for (i = 1; i <= 8; i++)
		n[i-1] = atof(argv[i]);
	for (j[0] = min; j[0] <= max; j[0]++)
		for (j[1] = min; j[1] <= max; j[1]++)
			for (j[2] = min; j[2] <= max; j[2]++)
				if ((n[0] == n[1] * j[0] + n[2] * j[1] + n[3] * j[2])
						&& (n[4] == n[5] * j[0] + n[6] * j[1] + n[7] * j[2]))
					fprintf (stdout, "našel: %f = %f * %f + %f * %f + %f * %f ; "
							"%f = %f * %f + %f * %f + %f * %f\n", n[0], n[1], j[0], n[2], j[1], n[3], j[2], n[4], n[5], j[0], n[6], j[1], n[7], j[2]);
	return 0;
}