|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 剑雨君 于 2014-9-24 18:21 编辑
- //不知道为什么我输不出小数点出来,请各位大神看看!!
复制代码- #include< iostream >
- #include <iomanip>
- using namespace std;
- typedef struct Student
- {
- char num[ 13 ]; //学号
- char name[ 9 ]; //姓名
- unsigned short int ue; //大学英语
- unsigned short int dm; //离散数学
- unsigned short int ds; //数据结构
- unsigned short int oop; //OOP
- float av; //平均成绩
- }Stu;
- int main()
- {
- Stu Student[ 100 ];
- int count; //人数
- int i;
- loop:
- cout << "请输入要录入成绩的人数:";
- cin >> count;
-
- if( count <= 0 )
- {
- cout << "输入错误!";
- goto loop;
- }
- for( i = 0; i < count; i++ )
- {
- cout << "学号: ";
- cin >> Student[ i ].num;
- cout << "姓名: ";
- cin >> Student[ i ].name;
- cout << "大学英语: ";
- cin >> Student[ i ].ue;
- cout << "离散数学: ";
- cin >> Student[ i ].dm;
- cout << "数据结构: ";
- cin >> Student[ i ].ds;
- cout << "OOP: ";
- cin >> Student[ i ].oop;
- Student[ i ].av = ( float )( ( Student[ i ].ue + Student[ i ].dm + Student[ i ].ds + Student[ i ].oop ) / 4 );
- cout << "平均成绩: ";
- cout << setprecision(4) << Student[ i ].av << endl;
- }
- i = 0;
- float all_av = 0.0;
- while( i < count )//计算全体学生的平均成绩
- {
- all_av += Student[ i ].av;
- i++;
- }
- cout << "全体学生的平均成绩:";
- cout << setprecision(4) << ( float )( ( all_av ) / i ) << endl;
- return 0;
- }
复制代码
|
|