填空題已知head指向一個(gè)單向鏈表,鏈表中每個(gè)節(jié)點(diǎn)包含整型數(shù)據(jù)域(data)和指針域(next)。以下函數(shù)sum求出鏈表中所有節(jié)點(diǎn)的數(shù)據(jù)域的和值,并作為函數(shù)值返回。#includestructlink{intdata;structlink*next;};voidmain(){structlink*head;ints,sum(structlink*);//省略建立鏈表程序s=sum(head);printf("sum=%d\n",s);}intsum(structlink*head){structlink*p;ints=0;p=head;while(){s+=;p=;}return();}

您可能感興趣的試卷

你可能感興趣的試題