From fc861aa2b6a5db06fbf886019dd0bdbb8243d2e9 Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 9 Apr 2020 23:50:22 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu5/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/du5/program.c b/du5/program.c index 112d9df..b4060f0 100644 --- a/du5/program.c +++ b/du5/program.c @@ -38,26 +38,26 @@ int main(){ int score=0; int c =0; char str[100]; - char digit[5]; + char digit; while(fgets(str,100,stdin)){ if(str[0]=='\n'){ break; } - sscanf(str,"%s %[^\t\n]",digit,name); - if(isalpha(digit[0])!=0){ + sscanf(str,"%c %[^\t\n]",&digit,name); + if(isalpha(digit)!=0){ if(c==0){ printf("Nepodarilo nacitat nic\n"); return 0; - } - break; + } } - int score = atoi(digit); + int score = digit-48>=0?digit-48:0; PersonList[c].score = score; strcpy(PersonList[c].name ,name); c++; + score=0; } - if(c>2){ + if(c>=2){ qsort(PersonList,c,sizeof(struct person),comp); int res_strcmp=0; int idex = 0;