2024-04-16 13:15:14 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
char pole[100][100];
|
|
|
|
int pocet_studentov = 0;
|
|
|
|
int ziadne_mena = 1;
|
|
|
|
|
2024-04-22 15:28:29 +00:00
|
|
|
char first_input[100];
|
|
|
|
if (fgets(first_input, sizeof(first_input), stdin) == NULL) {
|
2024-04-16 13:15:14 +00:00
|
|
|
printf("Nespravny vstup\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-04-22 15:28:29 +00:00
|
|
|
while (fgets(pole[pocet_studentov], sizeof(pole[pocet_studentov]), stdin) != NULL) {
|
|
|
|
if (pole[pocet_studentov][0] == '\n') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ziadne_mena = 0;
|
2024-04-16 13:15:14 +00:00
|
|
|
pole[pocet_studentov][strcspn(pole[pocet_studentov], "\n")] = '\0';
|
|
|
|
pocet_studentov++;
|
|
|
|
}
|
|
|
|
|
2024-04-22 15:28:29 +00:00
|
|
|
if (ziadne_mena) {
|
2024-04-16 13:15:14 +00:00
|
|
|
printf("Ziadne prihlasky\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-04-22 15:28:29 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < pocet_studentov - 1; i++) {
|
2024-04-16 13:15:14 +00:00
|
|
|
for (int j = i + 1; j < pocet_studentov; j++) {
|
|
|
|
if (strcmp(pole[i], pole[j]) > 0) {
|
|
|
|
char temp[100];
|
|
|
|
strcpy(temp, pole[i]);
|
|
|
|
strcpy(pole[i], pole[j]);
|
|
|
|
strcpy(pole[j], temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Prijati studenti:\n");
|
2024-04-22 15:28:29 +00:00
|
|
|
int pocet = atoi(first_input);
|
|
|
|
for (int i = 0; i < pocet && i < pocet_studentov; i++) {
|
2024-04-16 13:15:14 +00:00
|
|
|
printf("%s\n", pole[i]);
|
|
|
|
}
|
|
|
|
|
2024-04-22 15:28:29 +00:00
|
|
|
if (pocet < pocet_studentov) {
|
|
|
|
printf("Neprijati studenti:\n");
|
|
|
|
for (int i = pocet; i < pocet_studentov; i++) {
|
|
|
|
printf("%s\n", pole[i]);
|
|
|
|
}
|
2024-04-16 13:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|