不知道算不算动态链表。
程序代码:#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 5
struct stu_power
{
char *stu_name;
unsigned power;
struct stu_power *next;
}stu_list[N];
int main()
{
void print (struct stu_power *);
struct stu_power *head = &stu_list[0];
int n = 0;
while (n <= N) // || n+1 <= N ???
{
stu_list[n].stu_name = (char *)malloc(sizeof(char)*100);
scanf ("%s %d", stu_list[n].stu_name, &stu_list[n].power);
if (stu_list[n].power != 0)
{
stu_list[n].next = &stu_list[n+1];
realloc(stu_list[n].stu_name, strlen(stu_list[n].stu_name));
n++;
}
else
{
stu_list[n].next = NULL;
break;
}
}
print (head);
return 0;
}
void print (struct stu_power *head)
{
do
{
printf ("%s --> %d\n", head->stu_name, head->power);
head = head->next;
}while (head->next != NULL);
}这算动态链表吗,有什么可以改近的地方吗







貌似不是。。。我重写吧。。。


