Aktualizovat „du6/program.c“

This commit is contained in:
Artem Horbunov 2020-04-08 15:05:15 +00:00
parent 6e2ab46cfd
commit aaace41e0c

View File

@ -2,6 +2,7 @@
#include <string.h>
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++){