Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct student { char nume[21];
- int nr_matricol;
- int cod_materie[3];
- float medie_materie[3];
- struct student *urm;};
- typedef struct student elem;
- int main()
- {
- int i,n;
- scanf("%d",&n);
- elem *cap_lista, *p,*q;
- p=(elem*)malloc(sizeof(elem));
- if(p==NULL) exit(1);
- scanf("%s",&p->nume);
- scanf("%d",&p->nr_matricol);
- scanf("%d",&p->cod_materie);
- scanf("%f",&p->medie_materie);
- p->urm=NULL;
- cap_lista=p;
- for(i=2;i<=n;i++)
- { q=(elem*)malloc(sizeof(elem));
- if(q==NULL) exit(1);
- scanf("%s",&q->nume);
- /*scanf("%d",&q->nr_matricol);
- scanf("%d",&q->cod_materie);*/
- scanf("%f",&q->medie_materie);
- q->urm=NULL;
- p->urm=q;
- p=q;
- }
- float sum=0;
- for(p=cap_lista,i+1;p!=NULL;p=p->urm,i++)
- sum=sum+p->medie_materie;
- printf("%f",sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement