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

This commit is contained in:
Pavlo Tverdyi 2020-04-16 15:18:48 +00:00
parent 0b29479f3f
commit b1b107fb81

View File

@ -35,7 +35,10 @@ 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; if(names[0]=='\n'){
list[count].num=-1;
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){
@ -83,10 +86,6 @@ void print(struct LIS *list,int count,int places){
if(places>0){ if(places>0){
printf("Prijati studenti:\n"); printf("Prijati studenti:\n");
int i=1; int i=1;
if(count==1){
i=0;
count--;
}
for(i;i<=count;i++){ for(i;i<=count;i++){
if(list[i].num==2 && list[i].fname[0]!='\n'){ if(list[i].num==2 && list[i].fname[0]!='\n'){
printf("%s\n",list[i].fname); printf("%s\n",list[i].fname);
@ -111,4 +110,18 @@ void print(struct LIS *list,int count,int places){
else{ else{
puts("Ziadne prihlasky"); puts("Ziadne prihlasky");
} }
} }