Aktualizovat a3/program.c
This commit is contained in:
parent
8af04d02e4
commit
0e6bf56c36
12
a3/program.c
12
a3/program.c
@ -9,8 +9,9 @@
|
|||||||
struct studentApplication
|
struct studentApplication
|
||||||
{
|
{
|
||||||
char name[STUDENT_SIZE];
|
char name[STUDENT_SIZE];
|
||||||
|
char surname[STUDENT_SIZE];
|
||||||
};
|
};
|
||||||
void setMemoryOfArrays(char* processedName, struct studentApplication* student)
|
void setMemoryOfArrays(char* processedName, char* processedSurname, struct studentApplication* student)
|
||||||
{
|
{
|
||||||
//prednastavi pamat mnozinovych premien
|
//prednastavi pamat mnozinovych premien
|
||||||
processedName[0] = '\0';
|
processedName[0] = '\0';
|
||||||
@ -37,11 +38,12 @@ int main()
|
|||||||
struct studentApplication student[STUDENT_SIZE];
|
struct studentApplication student[STUDENT_SIZE];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char processedName[BUFFER_SIZE];
|
char processedName[BUFFER_SIZE];
|
||||||
|
char processedSurname[BUFFER_SIZE];
|
||||||
char newLineSymbol = '\n';
|
char newLineSymbol = '\n';
|
||||||
char line[BUFFER_SIZE];
|
char line[BUFFER_SIZE];
|
||||||
memset(line,0, sizeof(line));
|
memset(line,0, sizeof(line));
|
||||||
|
|
||||||
setMemoryOfArrays(processedName, student);
|
setMemoryOfArrays(processedName, processedSurname, student);
|
||||||
|
|
||||||
while (fgets(line, BUFFER_SIZE, stdin) != NULL)
|
while (fgets(line, BUFFER_SIZE, stdin) != NULL)
|
||||||
{
|
{
|
||||||
@ -49,7 +51,7 @@ int main()
|
|||||||
{
|
{
|
||||||
if(sscanf(line, "%d", &studentsAmount) == 1) { continue; }
|
if(sscanf(line, "%d", &studentsAmount) == 1) { continue; }
|
||||||
}
|
}
|
||||||
else if(sscanf(line, "%s", processedName) == 1)
|
else if(sscanf(line, "%s %s", processedName, processedSurname) == 2)
|
||||||
{
|
{
|
||||||
strcpy(student[i].name, processedName);
|
strcpy(student[i].name, processedName);
|
||||||
strncat(student[i].name, &newLineSymbol, 1);
|
strncat(student[i].name, &newLineSymbol, 1);
|
||||||
@ -62,8 +64,8 @@ int main()
|
|||||||
puts("Nespravny vstup");
|
puts("Nespravny vstup");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(student, STUDENT_SIZE, sizeof(struct studentApplication), compare);
|
qsort(student, studentsAmount, sizeof(struct studentApplication), compare);
|
||||||
|
|
||||||
// vypis vysledkov:
|
// vypis vysledkov:
|
||||||
puts("Prijati studenti:");
|
puts("Prijati studenti:");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user