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