From aaace41e0c34d9c6c923cb2640596436027d4026 Mon Sep 17 00:00:00 2001 From: Artem Horbunov Date: Wed, 8 Apr 2020 15:05:15 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu6/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du6/program.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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++){