#include<iostream>
#include<string>
using namespace std;
class student
{
public:
int num; //學號
string name; //姓名
int Chinese; //語文成績
int Math; //數學成績
int English; //英語成績
int Results; //總成績
student *next;
};
int main(){
cout << "請輸入學生的 學號,姓名,語文成績,數學成績,英語成績(空格隔開):" << endl;
int S = 0; //是平均成績
student *head;
student S1;
student S2;
student S3;
head = &S1;
cin >>S1.num>>S1.name>>S1.Chinese>>S1.Math>>S1.English;
S1.Results = S1.Chinese + S1.Math + S1.English;
S1.next = &S2;
cin >> S2.num>>S2.name>>S2.Chinese>>S2.Math>>S2.English;
S2.Results = S2.Chinese + S2.Math + S2.English;
S2.next = &S3;
cin >> S3.num>>S3.name>>S3.Chinese>>S3.Math>>S3.English;
S3.Results = S3.Chinese + S3.Math + S3.English;
S3.next = NULL;
S = S1.Results + S2.Results + S3.Results;
S /= 3;
cout << "三人總成績的平均分是:" << S << endl;
cout << "輸入你要查找的學生學號:" << endl;
int n;
cin >> n;
switch (n)
{
case 1:cout << "學號:" << S1.num << "\n" << "姓名:" << S1.name << "\n" << "語文成績:" << S1.Chinese << "\n數學成績:" << S1.Math << "\n英語成績" << S1.English << "\nta的平均成績:" << (S1.Chinese + S1.Math + S1.English)/3.0 << endl;
break;
case 2:cout << "學號:" << S2.num << "\n" << "姓名:" << S2.name << "\n" << "語文成績:" << S2.Chinese << "\n數學成績:" << S2.Math << "\n英語成績" << S2.English << "\nta的平均成績:" << (S2.Chinese + S2.Math + S2.English)/3.0 << endl;
break;
case 3:cout << "學號:" << S3.num << "\n" << "姓名:" << S3.name << "\n" << "語文成績:" << S3.Chinese << "\n數學成績:" << S3.Math << "\n英語成績" << S3.English << "\nta的平均成績:" << (S3.Chinese + S3.Math + S3.English)/3.0 << endl;
break;
default:cout <<"你輸入的學號無效"<< endl;
break;
}
cout << "您要對學生信息進行修改嗎?(T or F):" << endl;
char ch;
cin >> ch;
if (ch =='T')
{
cout << "請輸入要修改的學生的學號" << endl;
int i;
cin >> i;
switch (i)
{
case 1:cout <<"請輸入:姓名 語文成績 數學成績 英語成績"<< endl;
cin >>S1.name >> S1.Chinese >> S1.Math >> S1.English;
S1.Results = S1.Chinese + S1.Math + S1.English;
break;
case 2:cout << "請輸入 姓名 語文成績 數學成績 英語成績" << endl;
cin >>S2.name >> S2.Chinese >> S2.Math >> S2.English;
S2.Results = S2.Chinese + S2.Math + S2.English;
break;
case 3:cout << "請輸入 姓名 語文成績 數學成績 英語成績" << endl;
cin >>S3.name >> S3.Chinese >> S3.Math >> S3.English;
S3.Results = S3.Chinese + S3.Math + S3.English;
break;
default:cout << "您輸入的學號無效" << endl;
break;
}
}
else if (ch=='F')
{
cout << "謝謝使用!" << endl;
exit(0);
}
else
{
cout <<"您輸入了錯誤的字符,系統將在10秒後爆炸"<< endl;
exit(0);
}
system("pause");
return 0;
}
簡單的學生管理系統
製作一個簡單的學生管理系統
用C++的類創建一個簡單的學生管理系統:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.