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{
|
|
|
|
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);
|
|
|
|
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 19:09:03 +00:00
|
|
|
for(;fgets(list[count].fname,100,stdin);count++){
|
|
|
|
if(list[count].fname[0]=='\n'){
|
|
|
|
list[count].num=-1;
|
|
|
|
// printf("skip");
|
2020-04-16 13:16:09 +00:00
|
|
|
}
|
2020-04-16 19:09:03 +00:00
|
|
|
if(list[count].fname[0]!='\n'){
|
|
|
|
list[count].num=0;
|
|
|
|
}
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sort(struct LIS* list,int count){
|
2020-04-16 19:09:03 +00:00
|
|
|
|
|
|
|
struct LIS ilusion;
|
|
|
|
char *min;
|
|
|
|
char *mickro;
|
|
|
|
int mini;
|
2020-04-16 15:09:19 +00:00
|
|
|
for(int i=0;i<=count-1;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++){
|
2020-04-16 15:52:59 +00:00
|
|
|
if(strcmp(min,list[j].fname)>0){
|
2020-04-16 15:51:03 +00:00
|
|
|
min=list[j].fname;
|
|
|
|
mini=j;
|
2020-04-16 15:43:37 +00:00
|
|
|
}
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
2020-04-16 19:09:03 +00:00
|
|
|
ilusion=list[i];
|
|
|
|
list[i]=list[mini];
|
|
|
|
list[mini]=ilusion;
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
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 19:09:03 +00:00
|
|
|
|
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 19:09:03 +00:00
|
|
|
int k=0;
|
|
|
|
puts("Prijati studenti:");
|
|
|
|
for(int i=0;k!=places+1;i++){
|
|
|
|
if(list[i].num==0){
|
|
|
|
puts(list[i].fname);
|
|
|
|
k++;
|
2020-04-16 13:16:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(count-places>0){
|
2020-04-16 19:09:03 +00:00
|
|
|
int k=0;
|
|
|
|
puts("Neprijati studenti:");
|
|
|
|
for(int i=places+1;i<count;i++){
|
|
|
|
if(list[i].num==0){
|
|
|
|
puts(list[i].fname);
|
|
|
|
k++;
|
2020-04-16 13:16:09 +00:00
|
|
|
}
|
2020-04-16 19:09:03 +00:00
|
|
|
}
|
2020-04-16 00:16:00 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-16 15:51:03 +00:00
|
|
|
}
|
2020-04-16 15:57:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|