Update a4/program.c
This commit is contained in:
		
							parent
							
								
									9a3973e265
								
							
						
					
					
						commit
						e7334f2091
					
				
							
								
								
									
										15
									
								
								a4/program.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								a4/program.c
									
									
									
									
									
								
							@ -1,6 +1,7 @@
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
// Funkcia na overenie, či pole spĺňa podmienku binárnej minimálnej kopovitosti
 | 
			
		||||
bool is_min_heap(int arr[], int n) {
 | 
			
		||||
@ -43,17 +44,19 @@ int main() {
 | 
			
		||||
 | 
			
		||||
    // Načítanie vstupu
 | 
			
		||||
    // printf("Zadajte čísla oddelené medzerou: ");
 | 
			
		||||
    // if (!fgets(input, sizeof(input), stdin)) {
 | 
			
		||||
    // if (fgets(input, sizeof(input), stdin) == NULL) {
 | 
			
		||||
    //     printf("Chyba pri načítaní vstupu.\n");
 | 
			
		||||
    //     return 1;
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    // Odstránenie znaku nového riadku, ak existuje
 | 
			
		||||
    input[strcspn(input, "\n")] = '\0';
 | 
			
		||||
 | 
			
		||||
    // Parsovanie vstupu
 | 
			
		||||
    char *ptr = input;
 | 
			
		||||
    while (sscanf(ptr, "%d", &arr[n]) == 1) {
 | 
			
		||||
        n++;
 | 
			
		||||
        while (*ptr != ' ' && *ptr != '\0' && *ptr != '\n') ptr++; // Preskočiť číslo
 | 
			
		||||
        if (*ptr == ' ') ptr++; // Preskočiť medzeru
 | 
			
		||||
    char *ptr = strtok(input, " ");
 | 
			
		||||
    while (ptr != NULL) {
 | 
			
		||||
        arr[n++] = atoi(ptr);
 | 
			
		||||
        ptr = strtok(NULL, " ");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Ak je na vstupe len jedno číslo
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user