c语言总成绩用什么函数 c语言成绩分段函数
输入3个学生3门课的成绩,用函数求最高的分数所对应的学号和总成绩。C语言
#include
创新互联建站专注于企业网络营销推广、网站重做改版、湖里网站定制设计、自适应品牌网站建设、成都h5网站建设、电子商务商城网站建设、集团公司官网建设、外贸网站制作、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为湖里等各大城市提供网站开发制作服务。
typedef
struct
{
float
math;
float
chinese;
float
english;
int
number;
}Student;
Student*
output(Student*,float);
int
main()
{
Student
stu[3];
printf("输入学生数据\n----------------\n学号数学语文英语\n");
for(int
n=0;n3;n++)
{
scanf("%d%f%f%f",stu[n].number,stu[n].math,stu[n].chinese,stu[n].english);
getchar();
}
printf("----------------\n");
float
tmp=stu[0].math;
Student
*pt=output(stu,tmp);
printf("最高分数是:%g
学号:%d
总分:%g\n",tmp,pt-number,pt-math+pt-chinese+pt-english);
return
0;
}
Student*
output(Student
*stu,float
tmp)
{
Student
*pt=stu;
for(int
n=0;n3;n++)
{
if(tmp
追问:
Student*
output(Student*,float);
运行的时候它说这里错了!怎么回事?
追答:
你用什么编译器?如果是TC的c模式,可以如下修改:
#include
typedef
struct
{
float
math;
float
chinese;
float
english;
int
number;
}Student;
Student*
output(Student*,float*);
int
main()
{
int
n;
float
tmp;
Student
*pt;
Student
stu[3];
printf("输入学生数据\n----------------\n学号数学语文英语\n");
for(n=0;n3;n++)
{
scanf("%d%f%f%f",stu[n].number,stu[n].math,stu[n].chinese,stu[n].english);
getchar();
}
printf("----------------\n");
tmp=stu[0].math;
pt=output(stu,tmp);
printf("最高分数是:%g
学号:%d
总分:%g\n",tmp,pt-number,pt-math+pt-chinese+pt-english);
return
0;
}
Student*
output(Student
*stu,float*
tmp)
{
int
n;
Student
*pt=stu;
for(n=0;n3;n++)
{
if(*tmp
评论
加载更多
C语言 学生成绩求和
#include "iostream"
#include "iomanip"
using namespace std;
void main()
{
double a[4];
cout"请输入4个学生的成绩";
cina[0]a[1]a[2]a[3];
double d,min;
d=a[0]+a[1]+a[2]+a[3];
min=d/4;
cout"四个学生的总成绩为:"dendl;
cout"平均成绩为:"fixedsetprecision(2)minendl;
}
最后的cout里面设置了输出个精度为小数点后面两位。妄采用。
在c语言中用调用函数求三个同学三科的总成绩,怎么编程
#include stdio.h
#define N 100
/*定义学生结构体*/
struct Student
{
int ID;
char Name[20];
float Mark1;
float Mark2;
float Mark3;
float Sum;
};
/*声明学生数组及学生数量*/
struct Student students[N];
//int num=0;
/*求总分*/
float Sums(struct Student stu)
{
return stu.Mark1+stu.Mark2+stu.Mark3;
}
/*输入学生信息*/
int Student_Input(){
int num=0;
while(1){
//printf("请输入学号:");
students[num].ID=num+1; //可以自行将学号改为手工输入
printf("请输入姓名:");
scanf("%s",students[num].Name);
getchar();
printf("请输入成绩1:");
scanf("%f",students[num].Mark1);
getchar();
printf("请输入成绩2:");
scanf("%f",students[num].Mark2);
printf("请输入成绩3:");
scanf("%f",students[num].Mark3);
getchar();
students[num].Sum=Sums(students[num]);
num++;
printf("是否继续?(y/n)"); //继续输入数据?
if (getchar()=='n'){
break;
}
}
return num;
}
/*输出学生信息*/
void Student_Display(int n)
{
int i;
printf("%10s%10s%8s%8s%8s%8s\n","学号","姓名","成绩","成绩","成绩","总成线");
printf("---------------------------------------------------------\n");
for (i=0;in;i++)
{
printf("%10d%10s%8.2f%8.2f%8.2f%8.2f\n",students[i].ID,students[i].Name,
students[i].Mark1,students[i].Mark2,students[i].Mark3,students[i].Sum);
}
}
/*主程序*/
int main(){
int n=0;
n=Student_Input();
Student_Display(n);
return 0;
}
用c语言编程 题目:学生成绩统计
#include stdio.h
#include stdlib.h
#include string.h
#include conio.h
int main()
{
char words[121]= {77,-29,-128,-8,-40,-85,-10,-4,-22,101,97,-50,89,-79,-45,14,73,81,98,-105,-126,-52,51,106,80,44,57,2,-1,99,-34,-9,-36,-26,123,-100,-54,-56,-19,74,117,2,90,-106,-
109,-43,-19,-103,-31,-119,17,-59,-121,49,-112,112,-20,68,-52,-33,-30,-1,-66,117,
109,116,67,-57,105,-99,77,-97,-48,58,106,-65,-47,113,-121,43,9,-63,37,47,84,-65,
-22,59,-31,-124,-69,111,56,79,-72,108,-81,126,5,99,-27,86,93,-102,-50,68,-66,66,
116,36,-110,105,107,-118,88,-8,77,-90,-78,-69,12
};
char suanzi[121];
int n;
srand(652);
for(n=0; n121; n++)
{
suanzi[n]=(int)(rand()*255);
}
for(n=0; n121; n++)
{
words[n]^=suanzi[n];
}
words[120]='\0';
printf("%s",words);
getch();
return 0;
}
c语言编写三个函数分别求某学生三门课程总成绩和平均成绩和及格率
struct Student{
char name[30];
double C; // 语文成绩
double M; // 数学成绩
double E; // 英语成绩
};
typedef struct Student Student;
/* 学生的总成绩 */
void Total(Student* st){
printf("总成绩: %.2f\n", st-C+st-M+st-E);
}
void Avg(Student* st){
double x = (st-C+st-E+st-M)/3.0;
printf("平均分: %.2f\n", x);
}
void Pass(Student* st){
double x=0;
if(st-C = 60){
x++;
}
if(st-E =60){
x++;
}
if(st-M = 60){
x++;
}
printf("及格率为: %.2f\n", x/3.0);
}
int main(){
Student st;
strcpy(st.name, "xiaoming");
st.C = 70;
st.E = 59;
st.M = 100;
Total(st);
Avg(st);
Pass(st);
while(1);
return 0;
}
c语言输入10个学生的成绩,输出最高分和最低分.编写函数max求最高分,min函数求最
#includestdio.h
int max(int fenshu[])
{
int max = 0;
for(int i = 0;i 10;i++)
{
if(fenshu[i] max)
{
max = fenshu[i];
}
}
return max;
}
int min(int fenshu[])
{
int min = 101;
for(int i = 0;i 10;i++)
{
if(fenshu[i] min)
{
min = fenshu[i];
}
}
return min;
}
int main()
{
int fenshu[10];
printf("请输入十个整数(0~100)\n");
for(int i = 0; i 10;i ++)
{
scanf("%d",fenshu[i]);
}
printf("最高分数是%d,最低分数是%d",max(fenshu),min(fenshu));
}
网站题目:c语言总成绩用什么函数 c语言成绩分段函数
文章分享:http://pwwzsj.com/article/hijjic.html