#include #include #include #include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int compare(const void *a, const void *b) { const char **pa,**pb; pa = (const char **)a; pb = (const char **)b; return( strcmp(*pa,*pb) ) } int main() { int pocet_slov,pocet_znakov=0,i=0,count=0,number=0; bool zhoda=false; char* pole_smernikov[1000]={0}; char line[1000]; char cislo[1000]; fgets(cislo,1000,stdin); int dlzka=strlen(cislo); for(i=0;i='A' && line[i]<='Z')count; if(line[i]>='a' && line[i]<='z')count; } if(count==0){ //printf("Koniec"); break; } int size = (int)strlen(line); size--; while(size!=-1){ if(line[size]==' ' || line[size]=='\n' || line[size]==' '){ line[size]='\0'; } else{ break; } size--; } //printf("Retazec: #%s#\n",line); for(i=0;i pocet_slov; i++){ int size = (int)strlen(pole_smernikov[i]); size--; while(size!=0){ if(pole_smernikov[i][size]==' ' || pole_smernikov[i][size]=='\n' || pole_smernikov[i][size]==' '){ pole_smernikov[i][size]='\0'; } else{ break; } size--; } //printf("%d: %s\n",i+1,pole_smernikov[i]); } qsort(pole_smernikov,pocet_slov,sizeof(char *),compare); //printf("Sorted:\n"); if(pocet_slov<=number && number>0){ puts("Prijati studenti:"); for (i = 0; i < pocet_slov; i++){ printf("%s\n",pole_smernikov[i]); } } else{ puts("Prijati studenti:"); for (i = 0; i < number; i++){ printf("%s\n",pole_smernikov[i]); } puts("Neprijati studenti:"); for (i = number; i < pocet_slov; i++){ printf("%s\n",pole_smernikov[i]); } } for (i = 0; i < pocet_slov; i++){ free(pole_smernikov[i]); } return ; }