Добавить program.cv
This commit is contained in:
		
						commit
						7e47b63aa3
					
				
							
								
								
									
										37
									
								
								program.cv
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								program.cv
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
 | 
			
		||||
#define MAX_CONTESTANTS 50
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
    int results[MAX_CONTESTANTS];
 | 
			
		||||
    int count = 0, value;
 | 
			
		||||
    
 | 
			
		||||
    while (count < MAX_CONTESTANTS) {
 | 
			
		||||
        if (scanf("%d", &value) != 1 || value < 1) {
 | 
			
		||||
            printf("Chyba: Málo platných hodnôt.\n");
 | 
			
		||||
            return 1;
 | 
			
		||||
        }
 | 
			
		||||
        results[count++] = value;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    for (int i = 0; i < count; i++) {
 | 
			
		||||
        printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    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++) {
 | 
			
		||||
        if (results[i] == max_value) {
 | 
			
		||||
            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