Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct pointer{
- int info;
- struct pointer *link;
- } MyType;
- MyType *l,*p;
- const n=4;
- int d,i;
- float s;
- main()
- {
- l=NULL;
- for(i=1;i<=n;i++)
- {
- p=(MyType *)malloc(sizeof(MyType));
- printf("\nPhantu %d:",i);
- scanf("%d",&p->info);
- if(l==NULL)
- {
- p->link = NULL;
- l=p;
- }
- else {
- p->link =l;
- l=p;
- }}
- s=0;
- d=0;
- p=l;
- while(p!=NULL)
- {
- if(p->info %2 ==0)
- {
- d++;
- s=s+p->info;
- }
- p=p->link;
- }
- if(d!=0) printf("TBC = %f", s/d);
- else printf("Khong co phan tu nao chia het cho 2");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement