kompilator necita s porozumenim, chyba mi ciarka

This commit is contained in:
Kamil Gejdoš 2026-03-11 12:55:33 +00:00
parent 17ceaae191
commit 15eaa14bfd

View File

@ -4,6 +4,11 @@
#define SIZE 100 #define SIZE 100
struct student {
char name[SIZE];
int votes;
};
int compare(const void* p1, const void* p2) { //bolo v zadani na webe int compare(const void* p1, const void* p2) { //bolo v zadani na webe
struct student* s1 = (struct student*)p1; struct student* s1 = (struct student*)p1;
struct student* s2 = (struct student*)p2; struct student* s2 = (struct student*)p2;
@ -19,11 +24,6 @@ int compare(const void* p1, const void* p2) { //bolo v zadani na webe
//ak su hlasy rovnake, zistim, ktore meno je hore alebo dole abecedne //ak su hlasy rovnake, zistim, ktore meno je hore alebo dole abecedne
} }
struct student {
char name[SIZE];
int votes;
};
int main() { int main() {
//premenne //premenne
@ -53,13 +53,13 @@ int main() {
} }
//zoradit abecedne, potom zoradit mena podla poctov hlasov, poposuvat cisla hore //zoradit abecedne, potom zoradit mena podla poctov hlasov, poposuvat cisla hore
qsort(studenti, velkost_zoznamu, velkost_zoznamu - 1, compare); qsort(studenti, velkost_zoznamu, sizeof (struct studenti), compare);
//vystup vo formate printf("Vysledky:\n"); for i=0 to pocet_studentov //vystup vo formate printf("Vysledky:\n"); for i=0 to pocet_studentov
//printf("%d %s\n"student[i].votes, student[i].name[i]); //printf("%d %s\n"student[i].votes, student[i].name[i]);
printf("Vysledky:\n"); printf("Vysledky:\n");
for (int i = 0; i < velkost_zoznamu; i++) printf ("%d %s\n"studenti[i].votes, studenti[i].name); for (int i = 0; i < velkost_zoznamu; i++) printf ("%d %s\n", studenti[i].votes, studenti[i].name);
return 0; return 0;
} }