oprava asi
This commit is contained in:
		
							parent
							
								
									d805500070
								
							
						
					
					
						commit
						ccf621bbd2
					
				| @ -3,39 +3,32 @@ | |||||||
| #include <string.h> | #include <string.h> | ||||||
| 
 | 
 | ||||||
| int main() { | int main() { | ||||||
|     int pocet; |  | ||||||
|     char pole[100][100]; |     char pole[100][100]; | ||||||
|     int pocet_studentov = 0; |     int pocet_studentov = 0; | ||||||
|     int ziadne_mena = 1; |     int ziadne_mena = 1; | ||||||
| 
 | 
 | ||||||
|     while (fgets(pole[pocet_studentov], sizeof(pole[pocet_studentov]), stdin) != NULL) { |     char first_input[100]; | ||||||
|         if (sscanf(pole[pocet_studentov], "%d", &pocet) == 1 && pocet > 0) { |     if (fgets(first_input, sizeof(first_input), stdin) == NULL) { | ||||||
|             ziadne_mena = 0;  |  | ||||||
|             break; |  | ||||||
|         } |  | ||||||
|         printf("Nespravny vstup\n"); |         printf("Nespravny vstup\n"); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     while (fgets(pole[pocet_studentov], sizeof(pole[pocet_studentov]), stdin) != NULL) { | ||||||
|  |         if (pole[pocet_studentov][0] == '\n') { | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|  |         ziadne_mena = 0; | ||||||
|  |         pole[pocet_studentov][strcspn(pole[pocet_studentov], "\n")] = '\0'; | ||||||
|  |         pocet_studentov++; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     if (ziadne_mena) { |     if (ziadne_mena) { | ||||||
|         printf("Ziadne prihlasky\n"); |         printf("Ziadne prihlasky\n"); | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pocet_studentov++; |  | ||||||
| 
 | 
 | ||||||
|     while (pocet_studentov < 100 && fgets(pole[pocet_studentov], sizeof(pole[pocet_studentov]), stdin) != NULL) { |     for (int i = 0; i < pocet_studentov - 1; i++) { | ||||||
|         pole[pocet_studentov][strcspn(pole[pocet_studentov], "\n")] = '\0'; |  | ||||||
|         pocet_studentov++; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|     if (pocet_studentov == 1) { |  | ||||||
|         printf("Ziadne prihlasky\n"); |  | ||||||
|         return 1; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     for (int i = 1; i < pocet_studentov - 1; i++) { |  | ||||||
|         for (int j = i + 1; j < pocet_studentov; j++) { |         for (int j = i + 1; j < pocet_studentov; j++) { | ||||||
|             if (strcmp(pole[i], pole[j]) > 0) { |             if (strcmp(pole[i], pole[j]) > 0) { | ||||||
|                 char temp[100]; |                 char temp[100]; | ||||||
| @ -47,14 +40,17 @@ int main() { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     printf("Prijati studenti:\n"); |     printf("Prijati studenti:\n"); | ||||||
|     for (int i = 1; i <= pocet && i < pocet_studentov; i++) { |     int pocet = atoi(first_input);  | ||||||
|  |     for (int i = 0; i < pocet && i < pocet_studentov; i++) { | ||||||
|         printf("%s\n", pole[i]); |         printf("%s\n", pole[i]); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     if (pocet < pocet_studentov) { | ||||||
|         printf("Neprijati studenti:\n"); |         printf("Neprijati studenti:\n"); | ||||||
|     for (int i = pocet + 1; i < pocet_studentov; i++) { |         for (int i = pocet; i < pocet_studentov; i++) { | ||||||
|             printf("%s\n", pole[i]); |             printf("%s\n", pole[i]); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user