C语言编程改错
答案:4 悬赏:10 手机版
解决时间 2021-02-01 07:30
- 提问者网友:我没有何以琛的痴心不悔
- 2021-01-31 14:25
C语言编程改错
最佳答案
- 五星知识达人网友:千夜
- 2021-01-31 15:51
#include
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
main()
{
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
}
这样就可以了。少了个头文件的定义
并且在写scanf的时候多了几个 "
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
main()
{
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
}
这样就可以了。少了个头文件的定义
并且在写scanf的时候多了几个 "
全部回答
- 1楼网友:北城痞子
- 2021-01-31 17:48
缺少 stdio.h
修改后的
#include
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
void main(){
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
} ;
修改后的
#include
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
void main(){
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
} ;
- 2楼网友:第幾種人
- 2021-01-31 17:41
改好了 少了#include多了几个"
#include
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
void main()
{
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
}
#include
struct STUDENT {
char name[20];
int number;
int age;
float chinese,math,english,average;
};
void main()
{
struct STUDENT s1,s2,s3;
float ch,ma,eng;
int agee;
scanf("%s%d%d%f%f%f",s1.name,&s1.number,&s1.age,&s1.chinese,&s1.math,&s1.english);
scanf("%s%d%d%f%f%f",s2.name,&s2.number,&s2.age,&s2.chinese,&s2.math,&s2.english);
scanf("%s%d%d%f%f%f",s3.name,&s3.number,&s3.age,&s3.chinese,&s3.math,&s3.english);
s1.average=(s1.chinese + s1.math + s1.english)/3;
s2.average=(s2.chinese + s2.math + s2.english)/3;
s3.average=(s3.chinese + s3.math + s3.english)/3;
agee=(s1.age+s2.age+s3.age)/3;
ch=(s1.chinese+s2.chinese+s3.chinese)/3;
ma=(s1.math+s2.math+s3.math)/3;
eng=(s1.english+s2.english+s3.english)/3;
printf("%f,%f,%f,%d,%f,%f,%f",s1.average,s2.average,s3.average,agee,ch,ma,eng);
}
- 3楼网友:酒者煙囻
- 2021-01-31 16:05
有什么错误提示?
一个注释都没有,懒得看
一个注释都没有,懒得看
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯