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-16 13:16:09 +00:00
|
|
|
char name[100];
|
2020-04-16 00:16:00 +00:00
|
|
|
char fname[100];
|
2020-04-16 13:16:09 +00:00
|
|
|
int num;
|
2020-04-16 00:16:00 +00:00
|
|
|
};
|
2020-04-16 13:16:09 +00:00
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
char keep(struct LIS*,int);
|
|
|
|
void sort(struct LIS*,int);
|
2020-04-16 13:16:09 +00:00
|
|
|
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);
|
2020-04-16 13:16:09 +00:00
|
|
|
if(k!=1 || places<0){
|
2020-04-16 00:16:00 +00:00
|
|
|
puts("Nespravny vstup");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
int count=keep(list,places);
|
|
|
|
sort(list,count);
|
2020-04-16 13:31:07 +00:00
|
|
|
printf("%d",count);
|
2020-04-16 00:16:00 +00:00
|
|
|
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 count=0;
|
2020-04-16 13:16:09 +00:00
|
|
|
char names[100];
|
2020-04-16 13:31:07 +00:00
|
|
|
for(;fgets(names,100,stdin);count++){
|
2020-04-16 13:16:09 +00:00
|
|
|
if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){
|
|
|
|
if(places>=count){
|
|
|
|
list[count].num=0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
list[count].num=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(sscanf(names,"%s",list[count].fname)==1){
|
|
|
|
if(places>=count){
|
|
|
|
list[count].num=2;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
list[count].num=3;
|
|
|
|
}
|
|
|
|
}
|
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++){
|
2020-04-16 13:16:09 +00:00
|
|
|
min=list[i].fname;
|
2020-04-16 00:16:00 +00:00
|
|
|
mini=i;
|
2020-04-16 13:16:09 +00:00
|
|
|
for(int j=i+1;j<=count;j++){
|
|
|
|
if(strcmp(min,list[j].fname)>0){
|
|
|
|
min=list[j].fname;
|
2020-04-16 00:16:00 +00:00
|
|
|
mini=j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ilusion=list[i];
|
|
|
|
list[i]=list[mini];
|
|
|
|
list[mini]=ilusion;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-04-16 13:16:09 +00:00
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
void print(struct LIS *list,int count,int places){
|
2020-04-16 13:31:07 +00:00
|
|
|
if(count>0){
|
2020-04-16 13:16:09 +00:00
|
|
|
if(places>0){
|
2020-04-16 13:31:07 +00:00
|
|
|
puts("Prijati studenti:");
|
2020-04-16 13:16:09 +00:00
|
|
|
for(int i=0;i<=count;i++){
|
|
|
|
if(list[i].num==2){
|
|
|
|
printf("%s\n",list[i].fname);
|
|
|
|
}
|
|
|
|
if(list[i].num==0){
|
|
|
|
printf("%s %s\n",list[i].fname,list[i].name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(count-places>0){
|
|
|
|
printf("Neprijati studenti:\n");
|
|
|
|
for(int i=0;i<=count;i++){
|
|
|
|
if(list[i].num==3){
|
|
|
|
printf("%s\n",list[i].fname);
|
|
|
|
}
|
|
|
|
if(list[i].num==1){
|
|
|
|
printf("%s %s\n",list[i].fname,list[i].name);
|
|
|
|
}
|
|
|
|
}
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-16 13:16:09 +00:00
|
|
|
else{
|
|
|
|
puts("Ziadne prihlasky");
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-16 13:16:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-16 00:16:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-16 09:40:28 +00:00
|
|
|
|
2020-04-16 13:16:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|