回复 8楼 azzbcc
改了!不过输出不对啊 输出NULL
struct student stru[4] = {{"wang",24},{"wwe",27},{"wll",30},{"yyf",34}};
这里把它初始化为结构体数组也就是说不需要结构指针,因为stru[4]就已经把它们申明为静态内存并只需stru[i]就可以调动其中任意一个
同时细看会发现
程序代码:struct student
{
char name[10];
int age;
struct student *next;
};
并没有给next任何地址,而是只有调用它
程序代码: while(p != NULL)
{
array[i] = (p->age)-age;
p = p->next;
if(array[i]<0)
array[i] = 0 -array[i];
i++;
}
所以这个循环只会一次,或者说是错误的,因为next都没有初始化这并不是链表,上面说的其实都正确
不过只需稍加修改就行了,楼主加油吧









