123
This commit is contained in:
parent
70170f4869
commit
b48a9bc157
@ -9,15 +9,22 @@ int main() {
|
||||
char name[50];
|
||||
char **prihlasky = NULL;
|
||||
int counter = 0;
|
||||
prihlasky = (char **)malloc(max * sizeof(char *));
|
||||
if (scanf("%d", &max) != 1 || max <= 0) {
|
||||
puts("Nespravny vstup");
|
||||
return 1;
|
||||
}
|
||||
prihlasky = (char **)malloc(max * sizeof(char *));
|
||||
fgets(name, 50, stdin);
|
||||
while (fgets(name, 50, stdin) && name[0] != '\n') {
|
||||
prihlasky[counter] = strdup(name);
|
||||
counter++;
|
||||
int checker = 0;
|
||||
for(int i = 0;i < counter && i < max;i++){
|
||||
if(strcmp(prihlasky[i], name) == 0)
|
||||
checker = 1;
|
||||
}
|
||||
if(checker == 0){
|
||||
prihlasky[counter] = strdup(name);
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
qsort(prihlasky, counter, sizeof(char *), compare);
|
||||
puts("Prijati studenti:");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user