c语言从键盘输入5位同学3门成绩并对总和排序 c语言编程:输入5个学生3门课的成绩语文,数学,英语,a同学...

\u67095\u4e2a\u5b66\u751f\uff0c\u6bcf\u4e2a\u5b66\u751f\u7684\u6570\u636e\u5305\u62ec\u5b66\u53f7\u3001\u59d3\u540d\u3001\u4e09\u95e8\u8bfe\u7684\u6210\u7ee9\uff0c\u4ece\u952e\u76d8\u8f93\u51655\u4e2a\u5b66\u751f\u6570\u636e\uff0c\u8981\u6c42\u8f93\u51fa\u4e09\u95e8\u8bfe\u603b\u5e73\u5747

#include struct Student { int num; char name[20]; float score[3]; float aver; };//\u8fd9\u91cc\u8981\u5206\u53f7\u7684 \u628a\u8fd9\u4e2a\u7ed3\u6784\u4f53\u653e\u5230main\u51fd\u6570\u4e4b\u524dint main(){ void input(Student stu[]);//\u8fd93\u884c\u653e\u5230\u7ed3\u6784\u4f53Student\u540e\u9762 \u4e14\u53ef\u4ee5\u4e0d\u52a0\u5173\u952e\u8bcdstruct Student max(Student stu[]); void print(Student stu); Student stu[5],*p=stu;//\u8fd9\u91cc\u53ef\u4ee5\u4e0d\u8981strcut input(p); print(max(p)); return 0;}void input(Student stu[])//\u53ef\u4ee5\u4e0d\u52a0\u5173\u952e\u8bcdstruct{ int i,k; printf("\u8bf7\u8f93\u5165\u5b66\u751f\u59d3\u540d\u548c\u5b66\u53f7,\u4e09\u95e8\u8bfe\u6210\u7ee9\n"); for(i=0;istu[m].aver) { m=i; } } printf("\n\u6210\u7ee9\u6700\u9ad8\u7684\u5b66\u751f\u662f:\n");printf("\u5e73\u5747\u6210\u7ee9:%6.2f\n",stu[m].aver);//\u5e73\u5747\u6210\u7ee9\u5728\u8f93\u51fa\u51fd\u6570\u4e2d\u662f\u8f93\u4e0d\u51fa\u7684\u56e0\u4e3a\u8f93\u51fa\u51fd\u6570\u4e2d\u6ca1\u6709m\u7684\u503c return stu[m];}void print( Student stu){ printf("\u5b66\u53f7:%d\n\u59d3\u540d:%s\n\u4e09\u95e8\u8bfe\u6210\u7ee9:%5.1f%5.1f%5.1f\n",stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2]);}
\u4f60\u53ef\u4ee5\u81ea\u5df1\u52a8\u624b\u7f16\u51fa\u6765\u90a3\u4f60\u4e00\u5b9a\u4e5f\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u8981\u6c42\u518d\u6539\uff0c\u5f53\u7136\u8fd8\u6709\u8981\u6c42\u4e5f\u53ef\u4ee5\u8ffd\u95ee

#include double a[11][5]={0};int i,j;void scanfa(double b[11][5]){printf("\u8bf7\u4f9d\u6b21\u8f93\u5165\u6bcf\u4f4d\u540c\u5b66\u7684\u8bed\u6587\u3001\u6570\u5b66\u3001\u82f1\u8bed\u7684\u6210\u7ee9:\n");for(i=0;i<5;i++)for(j=0;j<3;j++)scanf("%lf",&b[i][j]);}void SumStu(double b[11][5])//\u8ba1\u7b97\u8f93\u51fa\u6bcf\u4e2a\u540c\u5b66\u7684\u603b\u5206{for(i=0;i<5;i++)for(j=0;j<3;j++)b[i][3]+=b[i][j];for(i=0;i<5;i++)printf("%.2lf\n",b[i][3]);}void SumSub(double b[10][5])//\u8ba1\u7b97\u8f93\u51fa\u6bcf\u95e8\u8bfe\u7a0b\u7684\u5e73\u5747\u5206{for(j=0;j<3;j++)for(i=0;i<5;i++)b[5][j]+=b[i][j];for(i=5,j=0;j<3;j++)printf("%.2lf ",b[i][j]);printf("\n");}int main(){scanfa(a);SumStu(a);SumSub(a);return 0;}

#include<stdio.h>
int main() 
{
int i, j, temp, sum = 0, total[10], 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; i++)
for (j=i+1; j<5; j++)
if (total[i] > total[j])
{
temp = total[i];
total[i] = total[j];
total[j] = temp;
}
printf ("对总成绩进行排序:
");
for (i=0; i<5; i++)
printf ("%d ", total[i]);
printf ("
");
}


  • 5浣瀛︾敓,姣忎釜鏈3闂璇剧殑鎴愮哗,浠庨敭鐩樿緭鍏瀛﹀彿,濮撳悕鍜3闂ㄨ鐨勬垚缁,璁$畻骞...
    绛旓細&stu[i].grade[0],&stu[i].grade[1],&stu[i].grade[2]);printf("The grade has enter.\n");average();} void average(){ float sum;int i,j;for(i=0;i<5;i++){ sum=0;for(j=0;j<3;j++)sum=sum+stu[i].grade[j];stu[i].aver=sum/3;} } 鍦╲c++涓皟璇曢氳繃 ...
  • 鏈浜斾釜瀛︾敓,姣忎釜瀛︾敓鏈涓夐棬璇剧▼鐨勬垚缁,浠庨敭鐩樿緭鍏瀛︾敓鏁版嵁(鍖呮嫭瀛﹀彿...
    绛旓細婧愪唬鐮佸涓嬶細include <stdio.h> define ID 11 typedef struct _stu { char id[ID];int sco1;int sco2;int sco3;}stu;int main(){ int i;stu s[5];FILE *fp;float ave;printf("璇杈撳叆浜斾釜瀛︾敓鐨勫鍙峰拰涓夐棬鎴愮哗锛歕n");for(i=0;i<5;i++){ scanf("%s%d%d%d",s[i].id,&s[...
  • 姹傚姪鍚勪綅澶х,C璇█绋嬪簭璁捐,杈撳叆5涓瀛︾敓杈撳叆瀛﹀彿濮撳悕涓3闂璇剧殑鎴愮哗
    绛旓細include<stdio.h>typedef struct {char num[20];char name[20];double a,b,c,sum;}STU;STU s[5];int main(){int i,j;STU t;for(i =0;i< 5;i++) {scanf("%s %s %lf %lf %lf",s[i].num,s[i].name,&s[i].a,&s[i].b,&s[i].c);s[i].sum = 0.1*s[i]....
  • C璇█:杈撳叆5涓瀛︾敓3闂璇剧▼鐨勬垚缁,鍒嗗埆鐢鍑芥暟瀹炵幇涓涓嬪姛鑳
    绛旓細int main(){ void max(int [][5]);void averagek(int [][5]);void averages(int [][5]);int a[10][5],i;for(i=0;i<=9;i++){ printf("璇杈撳叆绗%d鍚嶅鐢熶簲绉戞垚缁 锛",i+1);scanf("%d %d %d %d %d",&a[i][0],&a[i][1],&a[i][2],&a[i][3],&a[i][4...
  • ...鏈3闂璇剧▼鐨勬垚缁,缂栧啓鎴愮哗绠$悊绋嬪簭,瑕佹眰:鐢╟璇█瀹屾垚
    绛旓細for(i=0;i<5;i++){ printf("杈撳叆绗%d涓鐢熺殑瀛﹀彿銆佸鍚嶅強涓夐棬璇剧殑鎴愮哗锛歕n",i+1);scanf("%s%s%lf%lf%lf",stu[i].ID,stu[i].name,&stu[i].first,&stu[i].second,&stu[i].third);stu[i].average=(stu[i].first+stu[i].second+stu[i].third)/3.0;fprintf(_fp,"%s ...
  • c璇█:姹5浣嶅悓瀛3闂鍔熻鐨勫钩鍧囨垚缁,涓嶅強鏍肩殑杈撳嚭PALL,鍙婃牸鐨勫師鏍疯緭鍑...
    绛旓細浠g爜 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; ...
  • C璇█濉┖ 浠庨敭鐩樿緭鍏5鍚瀛︾敓鐨勫鍙枫佸鍚嶄互鍙3闂璇炬垚缁,璁$畻姣鍚嶅悓瀛...
    绛旓細绗竴绌猴細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>void main(){float temp[5][3];int i;float x1,x2,x3,x[5];for(i=0;i<5;i++){printf("璇杈撳叆瀛︾敓%d鐨勮鏂囨垚缁:",i+1); scanf("%f",&temp[i][0]);printf("璇疯緭鍏ュ鐢%d鐨勬暟瀛︽垚缁:",i+1); scanf("%f",&temp[i][1]);printf("璇疯緭鍏ュ鐢%d鐨勮嫳...
  • C璇█鍩虹棰樸傛湁5涓瀛︾敓,姣忎釜瀛︾敓鏈3闂璇剧殑鎴愮哗,浠庨敭鐩樿緭鍏瀛︾敓鏁版嵁
    绛旓細for(i=0;i<5;i++) //read { printf("number:");gets(p->number);printf("name:");gets(p->name);for (j=0;j<3;j++)switch(j){ case 0:printf("Mathematics:"); scanf("%d",&p->score[0]);break;case 1:printf("C Program:"); scanf("%d",&p->score[1]);break;cas...
  • 鏈浜斾釜瀛︾敓,姣忎釜瀛︾敓鏈涓夐棬璇剧殑鎴愮哗,浠庨敭鐩涓杈撳叆瀛︾敓鐨勫鍙,濮撳悕...
    绛旓細//瀹氫箟瀛︾敓绫绘暟缁,閲岄潰瀛樻斁浜斾釜瀛︾敓鐨勪俊鎭 Student[] stus = new Student[5];System.out.println("璇杈撳叆5涓瀛︾敓鐨勪俊鎭:");for(int i=0;i<stus.length;i++){ String str = sc.nextLine();//001 寮犱笁 78 88 90杈撳叆浠ョ┖鏍煎垎闅 //鍒╃敤String绫讳腑鐨剆plit鏂规硶灏嗗瓧绗︿覆鍒嗗壊鎴愬瓧绗︿覆鏁扮粍 String...
  • 扩展阅读:c十十编程要学多久 ... 祝老同学早上好语言 ... 老同学请客感谢语言 ... 同学聚会分别语言 ... c语言输入10个同学成绩 ... c语言一个&和两个& ... c十十编程难学吗 ... c语言查询学生成绩 ... 输入5个同学3门课的成绩 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网