diff --git a/du6/program.c b/du6/program.c index 378936d..9a42962 100644 --- a/du6/program.c +++ b/du6/program.c @@ -2,6 +2,7 @@ #include int main(){ + //Read num of lines int tmpCh; tmpCh = getc(stdin); if(tmpCh < '1' || tmpCh > '9'){ @@ -14,6 +15,7 @@ int main(){ scanf("%d", &lines); scanf("%*c"); + //Read names int realLines = 0; char names[200][200]; for(int i = 0; i < 200; i++){ @@ -30,9 +32,9 @@ int main(){ if(tmpCh == EOF) break; } + //Filter names char newNames[200][200]; int newLines = 0; - for(int i = 0; i < realLines; i++){ int check = 1; for(int q = 0; q < newLines; q++){ @@ -47,11 +49,12 @@ int main(){ } } + //Sort names for(int d = 0; d < newLines - 1; d++){ for(int i = 0; i < newLines - 1; i++){ int test = 0; for(int q = 0; q < newLines; q++){ - if(newNames[i][q] > newNames[i + 1][q]){ + if(newNames[i][q] > newNames[i + 1][q] || newNames[i][q] == -59){ char tmpName[50]; strcpy(tmpName, newNames[i]); strcpy(newNames[i], newNames[i + 1]); @@ -65,6 +68,7 @@ int main(){ } } + //Print names if(newLines <= lines){ puts("Prijati studenti:"); for(int i = 0; i < newLines; i++){