Создал(а) 'du2/program.c'
This commit is contained in:
parent
8d5cbded2b
commit
9de7cefa86
40
du2/program.c
Normal file
40
du2/program.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#define VELKOST_POLA 52
|
||||||
|
int main(){
|
||||||
|
int pole[VELKOST_POLA] = {0,0,0,0};
|
||||||
|
memset(pole,0,VELKOST_POLA * sizeof(int));
|
||||||
|
int value = 0;
|
||||||
|
int r = scanf("%d",&value);
|
||||||
|
int STOP = 1;
|
||||||
|
int i = 0;
|
||||||
|
int max_hodnota = 0;
|
||||||
|
int counter = 0;
|
||||||
|
while(STOP == 1){
|
||||||
|
if (r == 1){
|
||||||
|
printf("Úspešne som načítal hodnotu %d\n",value);
|
||||||
|
pole[i] = value;
|
||||||
|
i++;
|
||||||
|
r = scanf("%d",&value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
printf("\nNačítanie sa nepodarilo. V premennej value ostala pôvodná hodnota. \n");
|
||||||
|
STOP = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int j = 0; j < i; j++){
|
||||||
|
if (pole[j] > max_hodnota){
|
||||||
|
max_hodnota = pole[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int k = 0; k < i; k++){
|
||||||
|
counter++;
|
||||||
|
if(pole[k] == max_hodnota){
|
||||||
|
printf("\nwinner:%d", counter);
|
||||||
|
printf(" %d", max_hodnota);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user