1

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #define LIST_INIT_SIZE 100
 4 #define LISTINCREMENT 10
 5 #define OK 1
 6 #define ERROR 0
 7 #define OVERFLOW -2
 8 typedef struct LNode{
 9     int date;
10     struct LNode *next;
11 }LNode,*LinkList;
12 void CreateList(LinkList L,int n){
13     LinkList p;
14     L = (LinkList)malloc(sizeof(LNode));
15     int i;
16     if(L) printf("分配成功\n");
17     L->next = NULL;
18     for(i=0;i<n;i++){
19         p = (LinkList)malloc(sizeof(LNode));
20         int x; scanf("%d",&x);
21         p->next = L->next;
22         L->next = p;
23         p->date = x;
24     }
25 }
26 int Getlen(LinkList L){
27     int i,j,k,count = 0;
28     while(L){
29         count++;
30         L = L->next;
31     }
32     return count;
33 } 
34 int main(){
35     LinkList L;
36     int n;
37     scanf("%d",&n);
38     CreateList(L,n);
39     int len = Getlen(L);
40     printf("%d",len);
41     return 0;
42 }

 

posted @ 2020-09-25 10:42  西南大学  阅读(91)  评论(0)    收藏  举报