?? changescore.cpp
字號:
#include"head.h"
#include<iostream.h>
#include<stdlib.h>
#include<string.h>
extern void DisplayScore(Student* &);
void ChangeScore(Student* &head)
{
Student* pGuard;
char choice;
char Name[20];
int Class,Number,icount;
cout<<"已記錄的學生如下:"<<endl;
DisplayScore(head);
cout<<"說明:本程序提供①根據學生的學號"
<<" ②根據學生姓名和所在的班級"
<<" 兩種方式來查找并修改學生的成績."
<<endl;
status0:
cout<<"請選擇修改方式(1/2):";
cin>>choice;
system("cls");
if(choice=='1')
{
status1:
cout<<"請輸入要修改的學生的學號:"<<endl;
cin>>Number;
for(pGuard=head;pGuard!=NULL;pGuard=pGuard->next)
{
if(pGuard->Number==Number)
{
system("cls");
cout<<"找到該學生,已記錄的成績如下:"<<endl;
cout<<" 微積分成績: "<<pGuard->Score [0]<<endl;
cout<<" 物理成績: "<<pGuard->Score [1]<<endl;
cout<<" 英語成績: "<<pGuard->Score [2]<<endl;
cout<<" C語言成績: "<<pGuard->Score [3]<<endl;
cout<<" 體育成績: "<<pGuard->Score [4]<<endl;
cout<<"現在請輸入新的學生成績(如果沒有變化請按照原來的數值輸入):"<<endl;
status2:
cout<<endl<<"學生所學的科目為:微積分,物理,英語,C語言,體育.下面請分別輸入該學生的各科成績:"
<<endl;
for(icount=0,pGuard->Average=0.0;icount<MAX;icount++)
{
cin>>pGuard->Score[icount];
pGuard->Average+=pGuard->Score[icount];
}
pGuard->Average/=5;
status3:
cout<<"請核對以上信息,輸入內容完全無誤嗎? (y/n):"<<endl;
cin>>choice;
if(choice=='N'||choice=='n')
{
cout<<"那么請重新輸入吧."<<endl;
system("pause");
system("cls");
goto status2;
}
else if(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
{
cout<<"您鍵入的內容有錯,請重新選擇."<<endl;
system("pause");
system("cls");
goto status3;
}
cout<<"已成功修改該學生的信息!"<<endl;
return;
}
}
cout<<"沒有找到該學生的信息!"<<endl;
status4:
cout<<"要重新輸入學生的學號嗎?(y/n):";
cin>>choice;
if(choice=='y'||choice=='Y')
{
cout<<"那么請重新輸入吧!"<<endl;
system("pause");
goto status1;
}
else if(choice!='y'&&choice!='Y'&&choice!='n'&&choice!='N')
{
cout<<"您鍵入的內容有誤,請重新選擇."<<endl;
goto status4;
}
}
else if(choice=='2')
{
status5:
cout<<"請輸入要修改的學生的姓名:";
cin>>Name;
cout<<"請輸入學生所在的班級:";
cin>>Class;
for(pGuard=head;pGuard!=NULL;pGuard=pGuard->next)
{
if(pGuard->Class==Class&&strcmp(pGuard->Name,Name)==0)
{
cout<<"找到該學生,已記錄的成績如下:"<<endl;
cout<<" 微積分成績: "<<pGuard->Score [0]<<endl;
cout<<" 物理成績: "<<pGuard->Score [1]<<endl;
cout<<" 英語成績: "<<pGuard->Score [2]<<endl;
cout<<" C語言成績: "<<pGuard->Score [3]<<endl;
cout<<" 體育成績: "<<pGuard->Score [4]<<endl;
cout<<"現在請輸入新的學生成績(如果沒有變化請按照原來的數值輸入):"<<endl;
cout<<endl<<"學生所學的科目為:微積分,物理,英語,C語言,體育.下面請分別輸入該學生的各科成績:"
<<endl;
for(pGuard->Average=0.0,icount=0;icount<MAX;icount++)
{
cin>>pGuard->Score[icount];
pGuard->Average+=pGuard->Score[icount];
}
pGuard->Average/=5;
status6:
cout<<"請核對以上信息,輸入內容完全無誤嗎? (y/n):"<<endl;
cin>>choice;
if(choice=='N'||choice=='n')
{
cout<<"那么請重新輸入吧."<<endl;
system("pause");
system("cls");
goto status6;
}
else if(choice!='Y'&&choice!='y'&&choice!='N'&&choice!='n')
{
cout<<"您鍵入的內容有錯,請重新選擇."<<endl;
system("pause");
system("cls");
goto status6;
}
cout<<"已成功修改該學生的基本信息."<<endl;
return;
}
}
cout<<"沒有找到該學生的信息!"<<endl;
status7:
cout<<"要重新輸入學生的班級和姓名嗎?(y/n):";
cin>>choice;
if(choice=='y'||choice=='Y')
{
cout<<"那么請重新輸入吧!"<<endl;
system("pause");
goto status5;
}
else if(choice!='y'&&choice!='Y'&&choice!='n'&&choice!='N')
{
cout<<"您鍵入的內容有誤,請重新選擇."<<endl;
goto status7;
}
}
else if(choice!='1'&&choice!='2')
{
cout<<"您鍵入的內容有錯,請重新選擇."<<endl;
goto status0;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -