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

This commit is contained in:
Pavlo Tverdyi 2020-04-16 20:40:19 +00:00
parent 0764976b56
commit cc19e9fd6b

View File

@ -11,6 +11,7 @@ int num;
char keep(struct LIS*,int); char keep(struct LIS*,int);
void sort(struct LIS*,int); void sort(struct LIS*,int);
void print(struct LIS*,int,int); void print(struct LIS*,int,int);
void AAAAA(struct LIS*, int,int);
int main(){ int main(){
@ -24,6 +25,7 @@ if(k!=1 || places<0){
else{ else{
int count=keep(list,places); int count=keep(list,places);
sort(list,count); sort(list,count);
AAAAA(list,count,places);
print(list,count,places); print(list,count,places);
} }
return 0; return 0;
@ -69,19 +71,16 @@ int mini;
void print(struct LIS *list,int count,int places){ void print(struct LIS *list,int count,int places){
if(count>0){ if(count>0){
if(places>0){ if(places>0){
int i=0;
int k=0;
printf("Prijati studenti:\n"); printf("Prijati studenti:\n");
for(int i=0;k!=places;i++){ for(int i=0;i<count+count;i++){
if(list[i].num==0){ if(list[i].num>0){
fputs(list[i].fname,stdout); fputs(list[i].fname,stdout);
k++;
} }
} }
} }
if(count-places>0){ if(count-places>0){
printf("Neprijati studenti:\n"); printf("Neprijati studenti:\n");
for(int i=(count-places)+1;i<30;i++){ for(int i=0;i<count+count;i++){
if(list[i].num==0){ if(list[i].num==0){
fputs(list[i].fname,stdout); fputs(list[i].fname,stdout);
} }
@ -89,7 +88,18 @@ void print(struct LIS *list,int count,int places){
} }
} }
} }
void AAAAA(struct LIS* list, int count,int places){
int k=1;
for(int i=0;i<100;i++){
if(k!=places+1){
if(list[i].num==0){
list[i].num=k;
k++;
}
}
}
printf("%d",k);
}