Update 'du6/program.c'
This commit is contained in:
parent
4de1bb34d3
commit
f86e2cfbf6
@ -5,30 +5,35 @@
|
||||
|
||||
int main() {
|
||||
|
||||
char database[200][30];
|
||||
char base[200][30];
|
||||
char string[30];
|
||||
int error = 0;
|
||||
int count = 0;
|
||||
int i = 0;
|
||||
int stop = 0;
|
||||
int counter = 0;
|
||||
int a = 0;
|
||||
|
||||
memset(database, 0, sizeof(database));
|
||||
memset(base, 0, sizeof(base));
|
||||
memset(string, 0, 30);
|
||||
|
||||
char *r;
|
||||
r = fgets(string, 1000, stdin);
|
||||
if (r == NULL)
|
||||
return 0;
|
||||
sscanf(string, "%d", &count);
|
||||
if(strlen(r) == 1 || count < 1) {
|
||||
|
||||
sscanf(string, "%d", &counter);
|
||||
|
||||
if(strlen(r) == 1 || counter < 1) {
|
||||
puts("Nespravny vstup");
|
||||
return 0;
|
||||
}
|
||||
for (int c = 0; c < 30; c++) {
|
||||
if (isalpha(r[c])) {
|
||||
error = 1;
|
||||
|
||||
for (int b = 0; b < 30; b++) {
|
||||
if (isalpha(r[b])) {
|
||||
stop = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (error != 0) {
|
||||
|
||||
if (stop != 0) {
|
||||
puts("Nespravny vstup");
|
||||
return 0;
|
||||
}
|
||||
@ -39,43 +44,47 @@ int main() {
|
||||
r = fgets(string, 30, stdin);
|
||||
if (r == NULL)
|
||||
break;
|
||||
error = 0;
|
||||
for (int j = 0; j < 200; j++) {
|
||||
stop = 0;
|
||||
for (int c = 0; c < 200; c++) {
|
||||
|
||||
if (strcmp(database[j], string) == 0) {
|
||||
error = 1;
|
||||
if (strcmp(base[c], string) == 0) {
|
||||
stop = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (error == 0 && strlen(r) > 1) {
|
||||
strcpy(database[i], r);
|
||||
i++;
|
||||
if (stop == 0 && strlen(r) > 1) {
|
||||
strcpy(base[a], r);
|
||||
a++;
|
||||
}
|
||||
|
||||
}
|
||||
if (i == 0) {
|
||||
|
||||
if (a == 0) {
|
||||
puts("Ziadne prihlasky");
|
||||
return 0;
|
||||
}
|
||||
for (int j = 0; j < i; j++) {
|
||||
for (int k = 0; k < i; k++) {
|
||||
if (strcmp(database[j], database[k]) < 0) {
|
||||
|
||||
for (int d = 0; d < a; d++) {
|
||||
for (int f = 0; f < a; f++) {
|
||||
if (strcmp(base[d], base[f]) < 0) {
|
||||
char buffer[30];
|
||||
//memset(buffer, 0, sizeof(buffer));
|
||||
strcpy(buffer, database[j]);
|
||||
strcpy(database[j], database[k]);
|
||||
strcpy(database[k], buffer);
|
||||
|
||||
strcpy(buffer, base[d]);
|
||||
strcpy(base[d], base[f]);
|
||||
strcpy(base[f], buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
puts("Prijati studenti:");
|
||||
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (j == count) {
|
||||
if (j == counter) {
|
||||
puts("Neprijati studenti:");
|
||||
}
|
||||
printf("%s", database[j]);
|
||||
printf("%s", base[j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user