当前位置:首页 » 编程语言 » c语言四门课
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言四门课

发布时间: 2022-05-30 00:35:24

Ⅰ 编一程序,从键盘上输入四门功课成绩,求总成绩和平均成绩,并输出,(c语言)急用

用四个变量a,b,c,d分别表示输入的四门功课的成绩,用s表示总成绩,用av表示平均成绩并输出。程序如下:
#include <stdio.h>
int main()
{ int a,b,c,d,s;
float av;
scanf("%d%d%d%d",&a,&b,&c,&d);
s=a+b+c+d;
av=s/4.0;
printf("%d %.2f\n",s,av);
return 0;
}

Ⅱ C语言程序设计用数组求六个学生四门课中各科的最高分,最低分和平均分的程序代

#include <stdio.h>

#define N 6

int main()

{ int a[N+3][4]= {0},i,j;

for (i=0; i<N; i++)

{ for (j=0; j<4; j++)

{ scanf("%d",&a[i][j]);

a[N][j]+=a[i][j];

if(i==0)a[N+1][j]=a[N+2][j]=a[i][j];

else if(a[N+1][j]<a[i][j])

a[N+1][j]=a[i][j];

if(j==0)a[N+2][j]=a[i][j];

else if(a[N+2][j]>a[i][j])

a[N+2][j]=a[i][j];

}

}

for (j=0; j<4; j++)

printf("学科%d的平均分:%.2f 最高分:%d 最低分:%d ",j+1,a[N][j]/6.0,a[N+1][j],a[N+2][j]);

return 0;

}

Ⅲ c语言程序设计:任意输入4门课程的成绩,计算它们的平均值

代码如下:


main(){


int i;


double sum = 0, num;


for(i=1; i<5; i++){


printf("请输入第%d门课的成绩:", i);

scanf("%d",&i)


num = input.nextDouble();


sum+=num;


}


double average = sum/4;


printf("4门课成绩的平均分为:%.2f",average);


}


}

源代码截图:

Ⅳ 用c语言写 有三个学生四门课成绩,统计每人课程及各门课程的平均分

#include <stdio.h>
#define M 4
#define N 3
void main()
{
float score[M],add[N]={0},k[M]={0};
int i,j;
for(i=0;i<N;i++)
{
add[i]=0;
printf("输入第%d个学生%d门课程的成绩\n",i+1,M);
for(j=0;j<M;j++)
{
scanf("%f",score[j]);
add[i]+=score[j];
k[j]+=score[j];
}
}
for(i=0;i<N;i++)
printf("第%d个学生平均成绩:%.1f\n",i+1,add[i]/M);
for(i=0;i<M;i++)
printf("第%d门课的平均成绩:%.1f\n",i+1,k[i]/N);
}

Ⅳ C语言编程 输入一个学生四门课的成绩,计算平均成绩

#include “stdio.h”
void main(){
double scores[4];
double sum,avg;
printf("请输入四门课的成绩:");
for(int i=0;i<4;i++)
{
printf("第%d门成绩为: ",i);
scanf(score[i]);
printf("/n");
sum+=scores[i];
}
avg=sum/4;
printf("四门课平均成绩为%f",avg);
}

Ⅵ C语言:有3个学生,上4门课,输入全部学生的各门课程成绩,并分别求出每门课的平均成绩

#include <stdio.h>

struct score //假设四门课分别为语文,数学,英语,计算机。
{
float chinese;
float math;
float english;
float computer;
};
void main()
{
score st[3];
int i;
float avch=0;
float avma=0;
float aven=0;
float avco=0;

for(i=0;i<3;i++)
{
printf("请依次输入第%d个学生4门课的成绩:(顺序为语文,英语,数学,计算机)\n",i+1);
scanf("%f%f%f%f",&st[i].chinese,&st[i].math,&st[i].english,&st[i].computer);
}

for(i=0;i<3;i++)
{
avch+=st[i].chinese;
avma+=st[i].math;
aven+=st[i].english;
avco+=st[i].computer;
}

printf("\n语文的平均分为:%f",avch/3.0);
printf("\n数学的平均分为:%f",avma/3.0);
printf("\n英语的平均分为:%f",aven/3.0);
printf("\n计算机的平均分为:%f\n",avco/3.0);
}

Ⅶ C语言 有三个学生,上四门课,要求输入全部学生的各门课成绩,并分别求出每门课的平均成绩。

#include<stdio.h>

#defineMAX_STUDENT3//学生数
#defineMAX_SCORE4//学科数

intmain(intargc,char*argv[])
{
intscore[MAX_SCORE][MAX_STUDENT]={{0}};
intavg[MAX_SCORE]={0};
inti=0,j=0;

for(i=0;i<MAX_SCORE;i++)
{
for(j=0;j<MAX_STUDENT;j++)
{
printf("请输入第%d门课第%d个同学的成绩: ",i+1,j+1);
scanf("%d",&score[i][j]);

avg[i]+=score[i][j];
}
avg[i]/=MAX_STUDENT;
printf("第%d门课的平均成绩为:%d ",i+1,avg[i]);
}

return0;
}

这里没有考虑小数,自行考虑吧

Ⅷ C语言:有三个学生,上四门课,要求输入全部学生的各门课成绩,并分别求出每门课的平均成绩按升序输出

#include<stdio.h>
structstudent
{
charszName[100];
floatscore1;//课程1成绩
floatscore2;//课程2成绩
floatscore3;//课程3成绩
floatscore4;//课程4成绩
floatavgSocre;//平均成绩


//等号重载
studentoperator=(student&st)
{
sprintf(szName,st.szName);

score1=st.score1;
score2=st.score2;
score3=st.score3;
score4=st.score4;
avgSocre=st.avgSocre;

return*this;
}

//输出学生信息以及分数

voidprintfStu()
{
printf("%s %0.2f %0.2f %0.2f %0.2f %0.2f ",szName,score1,score2,score3,score4,avgSocre);
}


};

intmain()
{
constintstuCount=3;
studentstuArray[stuCount];

printf("姓名 课程1成绩 课程2成绩 课程3成绩 课程4成绩 ");

for(inti=0;i<stuCount;i++)
{

scanf("%s%f%f%f%f",
stuArray[i].szName,
&stuArray[i].score1,
&stuArray[i].score2,
&stuArray[i].score3,
&stuArray[i].score4);

stuArray[i].avgSocre=(stuArray[i].score1+stuArray[i].score2+
stuArray[i].score3+stuArray[i].score4)/4;

}

//排序
for(inti=0;i<stuCount;i++)
{
for(intj=0;j<stuCount-i-1;j++)
{
if(stuArray[j+1].avgSocre<stuArray[j].avgSocre)
{
studentstu=stuArray[j];
stuArray[j]=stuArray[j+1];
stuArray[j+1]=stu;
}
}
}

//打印
printf("姓名 课程1成绩 课程2成绩 课程3成绩 课程4成绩 平均成绩 ");

for(inti=0;i<stuCount;i++)
{
stuArray[i].printfStu();
}

return0;
}

运行结果如下:

Ⅸ c语言 输入5个学生的4门课成绩,用函数求出每门课平均成绩,在主函数输出平均成绩

摘要 "#include

Ⅹ c语言问题三个学生上四门课输入成绩求每门课平均成绩

#include<stdio.h>

intmain()
{
inti;
intsum=0;
for(i=0;i<3;i++)
{
sum=0;
inta,b,c,d;
printf("请输入学生%d四门课成绩,空格分隔 ",i+1);
scanf("%d%d%d%d",&a,&b,&c,&d);
sum+=a+b+c+d;
printf("课程%d平均成绩=%d ",i+1,(sum/4));
}
return0;
}