C语言:5个人3门课,求输出总成绩,平均成绩
C\u8bed\u8a00\u7f16\u7a0b\uff1a\u8f93\u51655\u540d\u5b66\u751f3\u95e8\u8bfe\u7a0b\u6210\u7ee9\u697c\u4e0a\u8bf4\u7684\u662f...\u8fd8\u6709\uff1a
stdsco \u6ca1\u6709\u8d4b\u521d\u503c\u8bf6...
\u6240\u4ee5\u7cfb\u7edf\u7ed9\u4e86\u4e00\u4e2a\u5f88\u5c0f\u7684\u503c\uff0c\u4f60\u5728 stdsco += sco;
\u8fd9\u91cc\u5b9e\u9645\u4e0a\u6ca1\u591a\u5927\u7528...\u90a3\u4e2a\u503c\u592a\u5c0f\u4e86...
\u5efa\u8bae\u5566\uff1a\u4ee5\u540e\u5728\u65b0\u5efa\u53d8\u91cf\u7684\u65f6\u5019\u5c31\u7ed9\u4ed6\u4e00\u4e2a\u521d\u503c...
\u5b9e\u73b0\u5e73\u53f0 Linux
\u6ca1\u6709\u8c03\u7528\u4ec0\u4e48\u5e93 windows\u5e73\u53f0\u53ef\u4ee5\u5b9e\u73b0
\u4ee3\u7801\u6709\u70b9\u5570\u55e6
\u53ea\u5199\u4e86\u4e00\u4e2a\u5b66\u751f\u7684 \u4f60\u770b\u4e86\u4ee5\u540e\u81ea\u5df1\u5c31\u53ef\u4ee5\u5b9e\u73b0\u540e\u9762\u7684\u5b66\u751f\u4e86
\u4f60\u662f\u521d\u5b66\u8005\u5427 \u8bb0\u5f97\u6bcf\u5929\u4e00\u5b9a\u8981\u5199\u51fa 300\u884c\u4ee3\u7801
#include
int main(void)
{
int lr[3];
int lri, LR_lr = 0, i;
printf("\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u5b66\u751f\u4e09\u95e8\u6210\u7ee9\n");
printf("\u6bcf\u8f93\u5165\u4e00\u4e2a\u6210\u7ee9\u56de\u8f66\u7ed3\u675f\n");
for(i = 0; i < 3; i++)
{
scanf("%d",&lri);
lr[i] = lri;
}
for (i = 0; i < 3; i++)
{
LR_lr += lr[i];
}
printf("\u7b2c\u4e00\u4e2a\u5b66\u751f\u7684\u603b\u6210\u7ee9\u4e3a:%d\n", LR_lr);
}
#include <stdio.h>
#include <string.h>typedef struct stud{
char name[50];
float chinese;
float math;
float english;
}student;void read(student *st,int n)
{
int i;
for(i=0;i<n;i++)
{
printf("输入第%d个学生的成绩\n",i+1);
printf("语文:");
scanf("%f",&st[i].chinese);
printf("数学:");
scanf("%f",&st[i].math);
printf("英语:");
scanf("%f",&st[i].english);
}
}student total(student *st,int n)
{
int i;
student s;
strcpy(s.name,"总成绩:\0");
s.chinese=0.0;
s.math=0.0;
s.english=0.0;
for(i=0;i<n;i++)
{
s.chinese += st[i].chinese;
s.math += st[i].math;
s.english += st[i].english;
}
return s;
}student average(student *st,int n)
{
student s;
student t = total(st,n);
strcpy(s.name,"平均成绩:\0");
s.chinese = t.chinese/n;
s.math = t.math/n;
s.english = t.english/n;
return s;
}int main()
{
int i;
student st[5];
student m,n;
read(st,5);
m = total(st,5);
n = average(st,5);
printf("%s 语文:%.2f;数学:%.2f;英语:%.2f\n ",m.name,m.chinese,m.math,m.english);
printf("%s 语文:%.2f;数学:%.2f;英语:%.2f\n ",n.name,n.chinese,n.math,n.english);
return 0;
}
输出5个人所有的成绩的品均值,还是单门课程的平均值?
绛旓細璁5涓汉3闂ㄨ锛屾眰杈撳嚭鎬鎴愮哗涓庡钩鍧囨垚缁#include <stdio.h> int main(){ float score = 0.0; float score_total = 0.0; float score_average = 0.0; int n1; int n2; for(n1=0;n1<5;n1++) { for(n2=0;n2<3;n2++) { printf("璇疯緭鍏ョ%d涓汉鐨...
绛旓細include <stdio.h>double a[11][5]={0};int i,j;void scanfa(double b[11][5]){printf("璇蜂緷娆¤緭鍏ユ瘡浣嶅悓瀛︾殑璇枃銆佹暟瀛︺佽嫳璇殑鎴愮哗:\n");for(i=0;i<5;i++)for(j=0;j<3;j++)scanf("%lf",&b[i][j]);}void SumStu(double b[11][5])//璁$畻杈撳嚭姣忎釜鍚屽鐨勬诲垎{for(i...
绛旓細include <stdio.h>int main(){ void Total_Score (float a[][3]); //瀛︾敓骞冲潎鍒 void Course_Max (float a[][3]); //璇剧▼骞冲潎鍒 int i, j; float score[5][3]; printf ("杈撳叆5涓鐢3闂ㄨ鐨勬垚缁╋細\n"); for (i=0; i<5; i++) { printf ("杈撳叆...
绛旓細scores[5][3];for (i=0; i<5; i++){printf ("杈撳叆绗 %d 浣嶅悓瀛3闂ㄨ鐨勬垚缁:", i+1);for (j=0; j<3; j++){scanf ("%d", &scores[i][j]);sum += scores[i][j];}total[i] = sum;}for (i=0; i<5;
绛旓細{ int i=0;int sum[5];int scr[5][3];while (i<5){ printf ("璇疯緭鍏ョ%d鍚嶅鐢熺殑鍥涚鎴愮哗锛屾瘡绉戞垚缁╀箣闂翠繚鐣欑┖鏍糪n",i);scanf("%d %d %d ",&scr[i][0],&scr[i][1],&scr[i][2]);i++;} i=0;//*閲嶇疆璁℃暟鍣 //杈撳嚭姣忎釜瀛︾敓鐨勬诲垎 while(i<5){ sum[i]=scr[i][0...
绛旓細绗竴绌猴細scanf("%d %s",&stu[i].num,stu[i].name);绗簩绌猴細scanf("%f",&stu[i].sco[j]);绗笁绌猴細stu[i].sum+=stu[i].sco[j];
绛旓細include <stdio.h>int main(int argc, const char * argv[]){ // 鎵撳嵃浜岀淮鏁扮粍浜斾釜瀛︾敓涓夐棬璇鐨勬瘡闂ㄨ鎴愮哗鍙鎬昏绋鐨勫钩鍧囩殑鎴愮哗 int score[][3] = { {67,89,90},{80,90,80},{59,43,78},{99,68,98},{56,89,67} };//鐜板湪鏄姹傝绋鐨勫钩鍧囧垎锛屾墍浠ュ寰幆鏄3锛屽唴寰幆鏄5 int ...
绛旓細include <stdio.h>#include <stdlib.h>struct student{ int socre[3]; int ave;};int main(){ struct student sut[5] = {{100,55, 89, 0}, {78, 80, 99, 0}, {98, 95, 100,0}, {40, 0, 50, 0}, {90, 100,100,0}}; int i,j,sum; ...
绛旓細绋嬪簭璁捐鎬濊矾锛氶鍏堟垜浠渶瑕佸畾涔変竴涓鐢熺殑缁撴瀯浣擄紝鐢ㄤ簬瀛樻斁瀛︾敓淇℃伅锛涙帴鐫鏄3涓柟娉曪紝涓涓緭鍏ュ鐢熶俊鎭殑鏂规硶锛屼竴涓槸璁$畻瀛︾敓姣闂ㄨ绋骞冲潎鎴愮哗鐨勶紝鏈鍚庝竴涓槸杈撳嚭瀛︾敓鎵鏈変俊鎭紝鍖呮嫭璁$畻濂界殑骞冲潎鎴愮哗锛屽叿浣撳疄鐜颁唬鐮佸涓嬶細include <stdio.h> include <stdlib.h>#define ARRAY_LEN 100 /*鏁扮粍闀垮害*/ ...
绛旓細struct student //瀹氫箟缁撴瀯浣擄紝鍖呮嫭瀛﹀彿锛屽鍚嶏紝鎴愮哗锛屽钩鍧囧垎锛屾绘垚缁 { int no;char name[10];int score[3];float ave;int sum;};int main(){ struct student s[5], temp;int i, j;printf("input 5 students' informations\n");for(i = 0; i < 5; ++i) //杈撳叆淇℃伅 { s...