Изменить 'du6/program.c'
^^
This commit is contained in:
parent
da111a7fd2
commit
0bfa0b68c9
@ -1,5 +1,67 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
return 0;
|
int freePlaces;
|
||||||
|
char inputs[100][50];
|
||||||
|
char* ptr;
|
||||||
|
int finalPosition;
|
||||||
|
int count = 0;
|
||||||
|
char temp[50];
|
||||||
|
|
||||||
|
for(int i =0; fgets(inputs[i], 50, stdin) != NULL;; i++){
|
||||||
|
if(i == 0){
|
||||||
|
freePlaces = strtol(inputs[0], &ptr, 10);
|
||||||
|
if(freePlaces < 0 || !sdigit(freePlaces)){
|
||||||
|
printf("Nespravny vstup\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(i == 1 && !salpha(inputs[i][0])){
|
||||||
|
printf("Ziadne prihlasky\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(!strcmp(inputs[i], "")){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalPosition = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Код ниже избавляется от повторных заявок
|
||||||
|
for(int i = 0; i < finalPosition; i++){
|
||||||
|
for(int j = 0; j < finalPosition; j++){
|
||||||
|
if(!strcmp(inputs[i], inputs[j])){
|
||||||
|
strcpy(inputs[i], inputs[finalPosition]);
|
||||||
|
memset(inputs[finalPosition], '\0', 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Этот код отвечает за сортировку заданных имён в списке зачисленных (а-я)
|
||||||
|
for(int i = 0; i < finalPosition - 1; i++){
|
||||||
|
while(inputs[i][count] == inputs[i+1][count]){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(inputs[i][count] > inputs[i+1][count]){
|
||||||
|
strcpy(temp, inputs[i]);
|
||||||
|
strcpy(inputs[i], inputs[i+1]);
|
||||||
|
strcpy(inputs[i+1], temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
puts("Prijati studenti:\n");
|
||||||
|
for(int i = 0; i < finalPosition; i++) {
|
||||||
|
puts ("%s\n", inputs[i]);
|
||||||
|
if(i == 4) break;
|
||||||
|
}
|
||||||
|
puts("Neprijati studenti:\n");
|
||||||
|
for(int i = 5; i < finalPosition; i++){
|
||||||
|
puts("%s\n", inputs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(ptr);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user