#include #include #include #include struct person{ int score; char name[30]; }; /* struct person* addElement(struct person **PersonList,int score,char *name){ static int size = 1; struct person *Personlist = calloc(size,sizeof(struct person)); size++; return Personlist; } */ int comp(const void *p1, const void *p2){ struct person* person1 = (struct person*)p1; struct person* person2 = (struct person*)p2; return strcmp(person1->name, person2->name)>0; } int comp_num(const void *p1, const void *p2){ struct person* person1 = (struct person*)p1; struct person* person2 = (struct person*)p2; return person1->scorescore; } int main(){ struct person PersonList[30]; char name[30]; int score=0; int c =0; char str[100]; char digit[2]; while(fgets(str,100,stdin)){ if(str[0]=='\n'){ break; } sscanf(str,"%s %[^\t\n]",&digit,name); if(isalpha(digit[0])!=0){ if(c==0){ printf("Nepodarilo nacitat nic\n"); return 0; } } int score = digit[0]-48>=0?((digit[0]-48)*10)+digit[1]-48:0; PersonList[c].score = score; strcpy(PersonList[c].name ,name); c++; score=0; } if(c>=2){ qsort(PersonList,c,sizeof(struct person),comp); int res_strcmp=0; int idex = 0; for(int i =0;i