代码如下:
#include
#include
struct students
{
char name[10];
char number[10];
int score;
struct students *next;
};
int main()
{
int i,j,k;
struct students stu[5],*head,*p;
char n[10],no[10];
for(i=0;i
{
printf("input the information of %dth student:\n",i+1);
scanf("%s%s%d\n",n,no,&stu[i].score);
strcpy(stu[i].name,n);
strcpy(stu[i].number,no);
}
head=&stu[0];
stu[4].next=NULL;
for(i=0;i
{
stu[i].next=&stu[i+1];
}
p=head;
printf("students list:\n");
while(p!=NULL)
{
printf("%s\t%s\t%d\n",p->name,p->number,p->score);
p=p->next;
}
}
实际运行结果如下奇怪:
请教一个问题,我的循环输入第一组数据和第二组数据一起输入了,但是最终 显示正常,求大神指教!!!
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- threenewbee 2017-09-22 00:42关注
scanf("%s%s%d\n",n,no,&stu[i].score); -> scanf("\n%s%s%d",n,no,&stu[i].score);
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥50 有数据,怎么建立模型求影响全要素生产率的因素
- ¥50 有数据,怎么用matlab求全要素生产率
- ¥15 TI的insta-spin例程
- ¥15 完成下列问题完成下列问题
- ¥15 C#算法问题, 不知道怎么处理这个数据的转换
- ¥15 YoloV5 第三方库的版本对照问题
- ¥15 请完成下列相关问题!
- ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
- ¥15 求daily translation(DT)偏差订正方法的代码
- ¥15 js调用html页面需要隐藏某个按钮