Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- struct Ocjena {
- char naziv_predmeta[51];
- int ocjena;
- };
- struct Student {
- char ime[21],prezime[21];
- int br_ocjena;
- struct Ocjena ocjene[100];
- };
- int jel_bio_student(struct Student *niz, int vel, struct Student stud){
- int i;
- for(i=0;i<vel;i++)
- if(strcmp(niz[i].ime,stud.ime)==0 && strcmp(niz[i].prezime,stud.prezime)==0 && niz[i].br_ocjena<100){
- strcpy(niz[i].ocjene[niz[i].br_ocjena].naziv_predmeta,stud.ocjene[0].naziv_predmeta);
- niz[i].ocjene[niz[i].br_ocjena].ocjena=stud.ocjene[0].ocjena;
- niz[i].br_ocjena++;
- return 1;
- }
- return 0;
- }
- double daj_prosjek_za_predmet(struct Student *niz, int vel, char *predmet){
- int brojac=0,i=0,j;
- double prosjek=0.;
- for(;i<vel;i++){
- for(j=0;j<niz[i].br_ocjena;j++)
- if(strcmp(predmet,niz[i].ocjene[j].naziv_predmeta)==0) brojac++, prosjek+=niz[i].ocjene[i].ocjena;
- }
- return prosjek/brojac;
- }
- ///Ucitavanje ide ok
- int ucitaj(struct Student *niz, int vel){
- FILE* ulaz=fopen("input.txt","r");
- if(ulaz==NULL)return 0;
- int i=0;
- while(i<vel && fscanf(ulaz,"%s %s %s %d\n",niz[i].ime,niz[i].prezime,niz[i].ocjene[0].naziv_predmeta,&niz[i].ocjene[0].ocjena)==4){
- //printf("%s %s %s %d\n",niz[i].ime,niz[i].prezime,niz[i].ocjene[0].naziv_predmeta,niz[i].ocjene[0].ocjena);
- if(jel_bio_student(niz,i,niz[i]))continue;
- else {
- niz[i].br_ocjena=1;i++;
- }
- }
- return i;
- }
- void koliko_ima_predemeta(struct Student *niz, int vel){
- int i,j,brojac=0;
- for(i=0;i<vel;i++){
- int bio=0;
- for(j=i+1;j<vel;j++){
- int k;
- for(k=0;k<niz[j].br_ocjena;k++)
- if(strcmp)
- }
- }
- }
- void zapisi(struct Student *niz, int vel){
- FILE* izlaz=fopen("output.txt","w");
- int i,prvi=0,drugi=0;
- ////???? POtrebno ubaciti predmete po alfabetu???, problem poredjenje i pamcenje koja imena su bila
- }
- int main(){
- struct Student niz[10];
- int vel=ucitaj(niz,10);
- int i,j;
- for(i=0;i<vel;i++){
- printf("%s %s:",niz[i].ime,niz[i].prezime);
- for(j=0;j<niz[i].br_ocjena;j++)
- printf("%s %d\n",niz[i].ocjene[j].naziv_predmeta,niz[i].ocjene[j].ocjena);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement