C#输入学生三门课的成绩,计算学生的平均成绩并显示

如题所述

主程序:
console.writeLine("请输入学生的三门课成绩:");
//假设成绩都是整数
int[] score=new int[3];
//输入的数据必须是整数才能转换成功,否则会引发异常
//输入成绩后要回车
score[0]=Conver.ToInt32(console.readLine());
score[1]=conver.toint32(console.readLine());
score[2]=conver.toint32(console.readLine());
int avrScore=(score[0]+score[1]+score[2]) / 3;
//输出平均成绩
console.writeLine("该学生的平均成绩是:{0}",avrScore);
//等待按下一个键(让你可以看到答案)
console.readKey();
温馨提示:答案为网友推荐,仅供参考
相似回答