Изменить 'du6/program.c'

This commit is contained in:
Pavlo Tverdyi 2020-04-16 14:52:03 +00:00
parent a541a20d95
commit 502f97862d

View File

@ -35,7 +35,9 @@ char keep(struct LIS* list,int places){
int count=0; int count=0;
char names[100]; char names[100];
for(;fgets(names,100,stdin);){ for(;fgets(names,100,stdin);){
if(names[0]=='\n') continue; for(int i=0; i<100;i++){
if(names[i]=='\n') continue;
}
if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){ if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){
count++; count++;
if(places>=count){ if(places>=count){
@ -82,18 +84,22 @@ void print(struct LIS *list,int count,int places){
if(count>0){ if(count>0){
if(places>0){ if(places>0){
printf("Prijati studenti:\n"); printf("Prijati studenti:\n");
for(int i=0;i<=count-1;i++){ int i=1;
if(list[i].num==2){ if(count==1){
i=0;
}
for(i;i<=count;i++){
if(list[i].num==2 && list[i].fname[0]!='\n'){
printf("%s\n",list[i].fname); printf("%s\n",list[i].fname);
} }
if(list[i].num==0){ if(list[i].num==0 && list[i].fname[0]!='\n'){
printf("%s %s\n",list[i].fname,list[i].name); printf("%s %s\n",list[i].fname,list[i].name);
} }
} }
} }
if(count-places>0){ if(count-places>0){
printf("Neprijati studenti:\n"); printf("Neprijati studenti:\n");
for(int i=0;i<=count-1;i++){ for(int i=0;i<=count;i++){
if(list[i].num==3){ if(list[i].num==3){
printf("%s\n",list[i].fname); printf("%s\n",list[i].fname);
} }