2020-04-13 21:49:38 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
struct LIS{
|
|
|
|
|
2020-04-13 21:49:38 +00:00
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
char fname[100];
|
|
|
|
char sname[100];
|
2020-04-13 21:49:38 +00:00
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
};
|
|
|
|
char keep(struct LIS*,int);
|
|
|
|
void sort(struct LIS*,int);
|
|
|
|
void print(struct LIS *,int,int);
|
2020-04-13 21:49:38 +00:00
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
int main(){
|
|
|
|
|
|
|
|
struct LIS list[100];
|
|
|
|
int places=0;
|
|
|
|
int k;
|
|
|
|
k=scanf("%d",&places);
|
|
|
|
if(k!=1 || places<=0){
|
|
|
|
puts("Nespravny vstup");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
int count=keep(list,places);
|
|
|
|
sort(list,count);
|
|
|
|
print(list,count,places);
|
|
|
|
}
|
2020-04-13 21:49:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
char keep(struct LIS* list,int places){
|
|
|
|
int num=places;
|
|
|
|
int stop;
|
|
|
|
int count=0;
|
|
|
|
char fn[100];
|
|
|
|
for(;stop!=EOF;count++,num--){
|
|
|
|
stop=fscanf(stdin,"%s %s",list[count].sname,list[count].fname);
|
|
|
|
}
|
2020-04-16 09:40:28 +00:00
|
|
|
count--;
|
2020-04-16 00:16:00 +00:00
|
|
|
return count;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void sort(struct LIS* list,int count){
|
|
|
|
struct LIS ilusion;
|
|
|
|
char *min;
|
|
|
|
int mini;
|
|
|
|
for(int i=0;i<count;i++){
|
|
|
|
min=list[i].sname;
|
|
|
|
mini=i;
|
|
|
|
for(int j=i+1;j<count;j++){
|
|
|
|
if(strcmp(min,list[j].sname)>0){
|
|
|
|
min=list[j].sname;
|
|
|
|
mini=j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ilusion=list[i];
|
|
|
|
list[i]=list[mini];
|
|
|
|
list[mini]=ilusion;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void print(struct LIS *list,int count,int places){
|
|
|
|
int j=0;
|
2020-04-16 09:40:28 +00:00
|
|
|
int nado=places;
|
|
|
|
if(places>count){
|
|
|
|
nado=count;
|
|
|
|
}
|
2020-04-16 00:16:00 +00:00
|
|
|
if(places>0){
|
2020-04-16 00:19:03 +00:00
|
|
|
puts("Prijati studenti:");
|
2020-04-16 09:40:28 +00:00
|
|
|
for(;j<nado;j++){
|
2020-04-16 09:41:12 +00:00
|
|
|
printf("%s %s\n",list[j].sname,list[j].fname);
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-16 00:19:03 +00:00
|
|
|
if(count-places>0)
|
2020-04-16 00:16:00 +00:00
|
|
|
puts("Neprijati studenti:\n");
|
|
|
|
for(int i=j;i<count;i++){
|
|
|
|
printf("%s %s\n",list[j].sname,list[j].fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-16 09:40:28 +00:00
|
|
|
|