Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
hledání max, min
#include <stdio.h> #define N 3 //všude nahraď N číslem 3 #define MAX 3.0 #define MIN -4.0 int main() { double data[N] = {0,}; // inicializace vsech prvku pole na 0 printf("Would you be so kind and insert %d number/numbers please?\n", N); // zadej N = 3 čísla for(int i = 0; i < N; ++i) //píšeme ++i a ne i++ { if(scanf("%lf", &data[i]) != 1) { printf("You have inserted incorrect data. The End of program\n"); return 1; } if((data[i] < MIN ) || ( data[i] > MAX)) { printf("Value %lf is out of range.\n", data[i]); --i; //return 2; continue; } printf("Zadano spravne cislo %lf\n", data[i]); } for(int i = 0; i < N; ++i) //vytiskne nam zadana cisla printf("%lf ", data[i]); putchar('\n'); double min = data[0], max = data[0]; for(int i = 1; i < N; ++i) //zjistuji nejvetsi a nejmensi cislo { if(min > data[i]) min = data[i]; if(max < data[i]) max = data[i]; } printf("Minimum is: %lf\n", min); printf("Maximum is: %lf\n", max); return 0; }
run
|
edit
|
history
|
help
0
test
1
try implicit return 0
inicializace struktury
Ukazatele - prohazování
struktury ++ vysvětlivky
TBod new
Ukazatele PR4
Stack
kvadratická rovnice