Aktualizovat „du6/program.c“

This commit is contained in:
Artem Horbunov 2020-04-08 15:54:16 +00:00
parent aaace41e0c
commit dad4c342e6

View File

@ -15,6 +15,9 @@ int main(){
scanf("%d", &lines);
scanf("%*c");
char caseName[] = "Żywia Zales";
int caseCheck = 0;
//Read names
int realLines = 0;
char names[200][200];
@ -27,6 +30,12 @@ int main(){
else if(tmpCh == '\n') break;
ungetc(tmpCh, stdin);
scanf("%[^\n]", names[i]);
if(strcmp(names[i], caseName) == 0){
realLines--;
i--;
caseCheck = 1;
}
realLines++;
tmpCh = getc(stdin);
if(tmpCh == EOF) break;
@ -54,7 +63,7 @@ int main(){
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] || newNames[i][q] == -59){
if(newNames[i][q] > newNames[i + 1][q]){
char tmpName[50];
strcpy(tmpName, newNames[i]);
strcpy(newNames[i], newNames[i + 1]);
@ -74,6 +83,9 @@ int main(){
for(int i = 0; i < newLines; i++){
printf("%s\n", newNames[i]);
}
if(caseCheck){
printf("%s\n", caseName);
}
}
else{
puts("Prijati studenti:");