1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char ** argv) {
if (argc != 1+4) {
fprintf(stderr, "uporaba: %s <sestevek a+b+c> <min> <max> <step>\nprimer: %s 1000 1 100 1\n", argv[0], argv[0]);
return 1;
}
unsigned int i;
double j[3];
double n[1];
double min = atoi(argv[2]);
double max = atoi(argv[3]);
double step = atoi(argv[4]);
for (i = 1; i <= 1; 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 ((j[0] < j[1] < j[2]) && (j[0] + j[1] + j[2] == n[0])
&& (pow(j[0],2) + pow(j[1],2) == pow(j[2],2)))
fprintf(stdout, "našel: %f^2 + %f^2 = %f^2 ; %f+%f+%f=%f\n", j[0],j[1], j[2], j[0], j[1], j[2], j[0]+j[1]+j[2]);
return 0;
}
|