高手请进。一个编程题目。

来源:百度知道 编辑:UC知道 时间:2024/06/17 22:21:51
找出下面程序的不足。谢了。

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <stdlib.h>
#define NULL 0
#define N 4
typedef struct Lnode
{int a;
struct Lnode *next;
}Lnode, * Linklist;
main(){
int i,n;
Linklist p,l,pa[N];
clrscr();
l=(Linklist)malloc(sizeof(Lnode));
l->next=NULL;
for(i=1;i<=N;i++)
{p=(Linklist)malloc(sizeof(Lnode));
pa[i-1]=p;
/*printf("input the number a\n");
scanf("%d",&(p->a));
getchar();*/

p->next=l->next;
l->next=p;
}
p=l->next;
for(i=1;i<=N;i++)
{ printf("input the number a\n");
scanf("%d",&(p->a));
getchar();
p=p->next;
}

for(i=0;i<N;i++)
{
if(i==N-1)

for(i=1;i<=N;i++)//创建一个空的链表结构
{p=(Linklist)malloc(sizeof(Lnode));
pa[i-1]=p;
p->next=l->next;
l->next=p;
}
p=l->next;
for(i=1;i<=N;i++)//依次输入
{ printf("input the number a\n");
scanf("%d",&(p->a));
getchar();
p=p->next;
}

要说缺点,也就是这两个可以放在一起做,省点时间复杂度把

/*printf("input the number a\n");
scanf("%d",&(p->a));
getchar();*/ 为什么要加解释说明符号呢?

malloc的都free了么?
这样的代码风格别人怎么读? 变量名就这么起 I,i,p ,pa?