#include "stdafx.h"
#include <iostream>
#include <map>
#include <string>
using namespace std;
struct Student
{
int number; //xuehao
char name[1024];
double yuwen;
double shuxue;
double yingyu;
};
class MyClass
{
public:
MyClass();
~MyClass();
private:
};
MyClass::MyClass()
{
}
MyClass::~MyClass()
{
}
int _tmain(int argc, _TCHAR* argv[])
{
/*
有五个学生,每个学生有3门课的成绩,从键盘输入以上数据(包括学生号,姓名,三门课成绩),
计算出平均成绩,
况原有的数据和计算出的平均分数存放在磁盘文件"stud"中。*/
cout << "请输入5个学生的成绩" << endl;
Student mStudent[5];
for (int i = 0; i < 5; i++)
{
cout << "请输入" << i + 1 << "个学生的学号" << endl;
cin >> mStudent[i].number;
cout << "请输入" << i + 1 << "个学生的姓名" << endl;
cin >> mStudent[i].name;
cout << "请输入" << i + 1 << "个学生的语文成绩" << endl;
cin >> mStudent[i].yuwen;
cout << "请输入" << i + 1 << "个学生的数学成绩" << endl;
cin >> mStudent[i].shuxue;
cout << "请输入" << i + 1 << "个学生的英语成绩" << endl;
cin >> mStudent[i].yingyu;
}
for (int i = 0; i < 5; i++)
{
cout << mStudent[i].number << "," << mStudent[i].name << "," << mStudent[i].yuwen << "," << mStudent[i].shuxue << "," << mStudent[i].yingyu << endl;
}
return 0;
}
C语言编程100例子
最新推荐文章于 2022-10-28 13:56:48 发布