标题:请问这个代码运行后总分为什么不对,哪里错了,怎样改?谢谢!
取消只看楼主
风雨同舟共济
Rank: 1
来 自:揭阳
等 级:新手上路
帖 子:10
专家分:0
注 册:2016-12-30
结帖率:100%
已结贴  问题点数:20 回复次数:0 
请问这个代码运行后总分为什么不对,哪里错了,怎样改?谢谢!
#include<stdio.h>
struct student{
int num;
char name;
int chinese,math,english,total;
};
void main()
{
int i,n;
struct student s[50],*p;
p=s;
void output_total(struct student *p,int n);
struct student input();
printf("输入学生的人数: ");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("输入第%d个学生的基本信息: \n",i);
s[i]=input();
output_total(s,n);
}
}
struct student input()
{
struct student s;
printf("学号 姓名 语文 数学 英语: \n");
scanf("%d%s%d%d%d",&s.num,&s.name,&s.chinese,&s.math,&s.english);
return s;
}
void output_total(struct student *p,int n)
{
(*p).total=(*p).chinese+(*p).math+(*p).english;
printf("总成绩为%d\n",(*p).total);
}


搜索更多相关主题的帖子: include english 英语 数学 信息 
2017-01-05 18:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-473329-1-1.html




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

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