- #include<stdio.h>
- #include<stdlib.h>
- struct list_node{
- int number;
- struct list_node * next;
- };
- typedef struct list_node node;
- typedef struct list_node * list_pointer;
- int sum_list(list_pointer l);
- int max_list(list_pointer l);
- int count_list(list_pointer l);
- int main()
- {
- int t;
- printf("Please input the number of nodes:");
- scanf("%d",&t);
- list_pointer first=NULL,temp=NULL;
- while(t--)
- {
- temp=(list_pointer)malloc(sizeof(node));
- temp->number=t+1;
- temp->next=first;
- first=temp;
- }
- printf("\\n%d\\n",sum_list(first));
- while(1);
- return 0;
- }
- int sum_list(list_pointer l)//ÏßDÔ±íÇóoíoˉêy
- {
- if(l==NULL) return 0;
- else return l->number+sum_list(l->next);
- }
- int max_list(list_pointer l)//ÇóÏßDÔ±í×î′óÖμoˉêy
- {
- int max;
- if(l==NULL) return 0;
- else{
- }
- }
- int count_list(list_pointer l)//ÇóÏßDÔ±íÖDÔaËظöêyoˉêy
- {
- if(l==NULL) return 0;
- else{
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/131120137123.html
来源: http://www.codesnippet.cn/detail/131120137123.html