Обновить du1/program.c
This commit is contained in:
		
							parent
							
								
									86c2edc97e
								
							
						
					
					
						commit
						23aa940839
					
				@ -1,43 +1,39 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#define MAX_SIZE 50
 | 
			
		||||
#define VELKOST_POLA 50
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
    int results[MAX_SIZE];
 | 
			
		||||
    int results[VELKOST_POLA];
 | 
			
		||||
    memset(results, 0, sizeof(results));
 | 
			
		||||
    int count = 0;
 | 
			
		||||
    int num;
 | 
			
		||||
 | 
			
		||||
    while (count < MAX_SIZE && scanf("%d", &num) == 1) {
 | 
			
		||||
        if (num < 1) {
 | 
			
		||||
            printf("Chyba: Málo platných hodnôt.\n");
 | 
			
		||||
            return 1;
 | 
			
		||||
    int value;
 | 
			
		||||
    while (count < VELKOST_POLA) {
 | 
			
		||||
        if (scanf("%d", &value) != 1) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        results[count++] = num;
 | 
			
		||||
        if (value < 1) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        results[count++] = value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if (count == 0) {
 | 
			
		||||
        printf("Chyba: Málo platných hodnôt.\n");
 | 
			
		||||
        return 1;
 | 
			
		||||
        return 0;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    int max_val = INT_MIN;
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        if (results[i] > max_val) {
 | 
			
		||||
            max_val = results[i];
 | 
			
		||||
    int max = results[0];
 | 
			
		||||
    for (int i = 1; i < count; i++) {
 | 
			
		||||
        if (results[i] > max) {
 | 
			
		||||
            max = results[i];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        if (results[i] == max_val) {
 | 
			
		||||
        if (results[i] == max) {
 | 
			
		||||
            printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user