#include
創(chuàng)新互聯(lián)專注于大邑縣企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),商城建設(shè)。大邑縣網(wǎng)站建設(shè)公司,為大邑縣等地區(qū)提供建站服務(wù)。全流程定制網(wǎng)站建設(shè),專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)專業(yè)和態(tài)度為您提供的服務(wù)
#include
#define N 9
typedef struct node{
int data;
struct node * next;
}ElemSN;
ElemSN * Createlink(int a[],int n){
int i;
ElemSN * h=NULL, * p;
for( i=N-1;i>=0;i--){
p=(ElemSN *)malloc(sizeof(ElemSN));
p->data =a[i];
p->next=h;
h=p;
}
return h;
}
int CoundOddNode(ElemSN*h){
int Odd=0; //奇數(shù)個(gè)數(shù)
ElemSN * p;
for(p=h;p;p=p->next)
Odd=Odd+p->data%2; //奇數(shù)data%2=0偶數(shù)data%2=1,奇數(shù)odd就加1
return Odd;
}
int main(void){
int Odd;
int a[]={1,2,3,4,5,6,7,8,9};
ElemSN *head;
head=Createlink(a,9);
Odd=CoundOddNode(head);
printf("奇數(shù)結(jié)點(diǎn)個(gè)數(shù)=%2d\n",Odd);
return 0;
}