Обновить du1/program.c
This commit is contained in:
		
							parent
							
								
									3d71a37565
								
							
						
					
					
						commit
						5adbc45d85
					
				@ -1,39 +1,31 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
    int results[50];
 | 
			
		||||
    int count = 0;
 | 
			
		||||
    int number;
 | 
			
		||||
    
 | 
			
		||||
    while (count < 50 && scanf("%d", &number) == 1) {
 | 
			
		||||
        if (number >= 1) {
 | 
			
		||||
 | 
			
		||||
    while (scanf("%d", &number) == 1) {
 | 
			
		||||
        if (number > 0) {
 | 
			
		||||
            results[count] = number;
 | 
			
		||||
            count++;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
        printf("Chyba: Málo platných hodnôt.\n");
 | 
			
		||||
        return 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int max_value = results[0];
 | 
			
		||||
    for (int i = 1; i < count; i++) {
 | 
			
		||||
        if (results[i] > max_value) {
 | 
			
		||||
            max_value = results[i];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        if (results[i] == max_value) {
 | 
			
		||||
            printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
 | 
			
		||||
    int max_value = results[0];
 | 
			
		||||
    int winner_index = 0;
 | 
			
		||||
    for (int i = 1; i < count; i++) {
 | 
			
		||||
        if (results[i] > max_value) {
 | 
			
		||||
            max_value = results[i];
 | 
			
		||||
            winner_index = i;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", winner_index + 1, max_value);
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user