鱼C论坛

 找回密码
 立即注册
查看: 3847|回复: 1

C语言链表怎么输出第一个数组

[复制链接]
发表于 2012-12-6 16:27:14 | 显示全部楼层 |阅读模式
5鱼币
#include "stdio.h"
struct str
{
char nema[10];
int  n;
struct str *next;
}ne[3]={{"AAA",20},{"BBB",18},{"CCC",17},};
void k(struct str *c)
{
struct str *p=NULL;
p=c;
printf("%s  %d\n",p->next->nema,p->next->n);
p=p->next;
printf("%s  %d\n",p->next->nema,p->next->n);
p=p->next;
printf("%s  %d\n",p->next->nema,p->next->n);
}
int main()
{
struct str *p=NULL;
p=&ne[0];
ne[0].next=&ne[1];
ne[1].next=&ne[2];
ne[2].next=&ne[3];
ne[3].next=NULL;
k(p);
return 0;
}


怎么输出 第一个数组 内容{"AAA",20}


想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2012-12-6 16:27:15 | 显示全部楼层
#include "stdio.h"
struct str
{
char nema[10];
int  n;
struct str *next; 
}ne[3]={{"AAA",20},{"BBB",18},{"CCC",17},};
void k(struct str *c)
{
struct str *p=NULL;
p=c;
printf("%s  %d\n",p->nema,p->n);
p=p->next;
printf("%s  %d\n",p->nema,p->n);
p=p->next;
printf("%s  %d\n",p->nema,p->n);
}
int main()
{
struct str *p=NULL;
p=&ne[0];
ne[0].next=&ne[1];
ne[1].next=&ne[2];
ne[2].next=&ne[3];
ne[3].next=NULL;
k(p);
return 0;
} 
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-6 06:30

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表