diff --git a/Makefile b/Makefile index c02bb17..6706dd8 100644 --- a/Makefile +++ b/Makefile @@ -10,3 +10,8 @@ clean: anketa: anketa.o main.o gcc anketa.o main.o -o anketa +.PHONY: git +git: + git add . + git commit -am "test" + git push diff --git a/anketa b/anketa index bb61039..7742f1a 100755 Binary files a/anketa and b/anketa differ diff --git a/anketa.c b/anketa.c index 28eb939..3acc53c 100644 --- a/anketa.c +++ b/anketa.c @@ -31,8 +31,10 @@ int add_student(struct student* students, const char* name, int votes){ if(index==-1&&pocet +#include -int main(){ +void count_votes(struct student* students){ + int sum=0; + for(int i=0;i1){ + FILE* fr=fopen(argv[1],"r"); + read_students(fr,students); + switch(argv[2][1]){ + case 'h': printf("-h vypise navod na ovladanie.\n-s vyhlada zadane meno.\n-p vypise vyslednu databazu mien.\n-o zotriedi vyslednu databazu podla pocetnosti.\n-c vypise pocet vsetkych odovzdanych hlasov.\n-i vypise pocet studentov, ktori dostali aspon jeden hlas.\n"); + break; + case 's': index=search(students,argv[3]); + if(index!=-1){ + printf("%s\n %d\n", students[index].name, students[index].votes); + }else{ + printf("Hladany student sa nenasiel.\n"); + } + break; + case 'p': print_students(students); + break; + case 'o': sort_students(students); + break; + case 'c': count_votes(students); + break; + case 'i': printf("%d\n", count_students(students)); + break; + } +} + /* int sz = count_students(students); if (sz <= 0){ // Nenacitalo sa nic return 0; } - sort_students(students); - print_students(students); + + print_students(students);*/ return 0; } diff --git a/main.o b/main.o index e618f77..d754cad 100644 Binary files a/main.o and b/main.o differ diff --git a/vstup.txt b/vstup.txt index 6bed1e0..0a41421 100644 --- a/vstup.txt +++ b/vstup.txt @@ -1,4 +1,5 @@ -Anka Lesna +Anka 10 -Marcel Novotny +Marcel 30 +