| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 614 人关注过本帖
标题:关于本站上的一个例子
只看楼主 加入收藏
有敌手
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2008-2-12
收藏
 问题点数:0 回复次数:0 
关于本站上的一个例子
#define ERROR 0
#define OK 1
struct STU
{ char name[20];
char stuno[10];
int age; int score;
}stu[50];
struct LIST
{ struct STU stu[50];
int length;
}L;

int printlist(struct LIST L)
{ int i;
printf("name stuno age score\n");
for(i=0;i<L.length;i++)
printf("%s %s\t%d\t%d\n", L.stu[i].name, L.stu[i].stuno, L.stu[i].age, L.stu[i].score);
printf("\n");
}

int listinsert(struct LIST *L,int i,struct STU e)
{ struct STU *p,*q;
if (i<1||i>L->length+1)
return ERROR;
q=&(L->stu[i-1]);
for(p=&L->stu[[color=Blue]L->length-1];p>=q;--p) [/color]*(p+1)=*p; *q=e; ++L->length; //男色字的那里,值为-1,但是数组值是从0开始的。。。这个何解?
return OK;
}/*ListInsert Before i */

main()
{ struct STU e;
L.length=0;
strcpy(e.name,"zmofun");
strcpy(e.stuno,"100001");
e.age=80;
e.score=1000;
listinsert(&L,1,e);
printlist(L);
printf("List length now is %d.\n\n",L.length);

strcpy(e.name,"bobjin");
strcpy(e.stuno,"100002");
e.age=80;
e.score=1000;
listinsert(&L,1,e);
printlist(L);
printf("List length now is %d.\n\n",L.length);
}
搜索更多相关主题的帖子: int struct STU stu 例子 
2008-05-17 22:53
快速回复:关于本站上的一个例子
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011215 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved