⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c++学生系统代码3.txt

📁 学生系统 计算学生分数.xxxxxxxxxx
💻 TXT
📖 第 1 页 / 共 2 页
字号:
if(maxNum<int(head->chinaNum)) 
{ 
maxNum=int(head->chinaNum); 
} 
} 
else if (type=='2') 
{ 
if(maxNum<int(head->mathNum)) 
{ 
maxNum=int(head->mathNum); 
} 
} 
else if (type=='3') 
{ 

if(maxNum<int(head->englishNum)) 
{ 
maxNum=int(head->englishNum); 
} 
} 
else if (type=='4') 
{ 
if(maxNum<int(head->result)) 
{ 
maxNum=int(head->result); 
} 
} 
else if (type=='5') 
{ 
if(maxNum<int(head->average)) 
{ 
maxNum=int(head->average); 
} 
} 
else if (type=='6') 
{ 
if(maxNum<head->pos) 
{ 
maxNum=head->pos; 
} 
} 
} 
else 
{ 
if(type=='1') 
{ 

if(maxNum>int(head->chinaNum)) 
{ 
maxNum=int(head->chinaNum); 
} 
} 
else if (type=='2') 
{ 
if(maxNum>int(head->mathNum)) 
{ 
maxNum=int(head->mathNum); 
} 
} 
else if (type=='3') 
{ 

if(maxNum>int(head->englishNum)) 
{ 
maxNum=int(head->englishNum); 
} 
} 
else if (type=='4') 
{ 
if(maxNum>int(head->result)) 
{ 
maxNum=int(head->result); 
} 
} 
else if (type=='5') 
{ 
if(maxNum>int(head->average)) 
{ 
maxNum=int(head->average); 
} 
} 
else if (type=='6') 
{ 
if(maxNum>head->pos) 
{ 
maxNum=head->pos; 
} 
} 
} 
head=head->next; 
} 

head=pHead; 

cout<<"姓名:"<<setw(8)<<"座号:"<<setw(10) 
<<"语文分数:"<<setw(10) <<"数学分数:" 
<<setw(10)<<"英语分数:"<<setw(8)<<"总分数:" 
<<setw(8)<<"平均分:"<<setw(5)<<"名次:"<<endl<<endl; 

while(head) 
{ 
if(type=='1') 
{ 
if(int(head->chinaNum)==maxNum) 
{ 
Print(head); 
} 
} 
else if (type=='2') 
{ 
if(int(head->mathNum)==maxNum) 
{ 
Print(head); 
} 
} 
else if (type=='3') 
{ 
if(int(head->englishNum)==maxNum) 
{ 
Print(head); 
} 
} 
else if (type=='4') 
{ 
if(int(head->result)==maxNum) 
{ 
Print(head); 
} 
} 
else if (type=='5') 
{ 
if(int(head->average)==maxNum) 
{ 
Print(head); 
} 
} 
else if (type=='6') 
{ 
if(head->pos==maxNum) 
{ 
Print(head); 
} 
} 

head=head->next; 
} 

} 

void Reword(student *pStd) 
{ 

if(pStd!=NULL) 
{ 
cout<<"请输入学生的新名字:"<<endl; 
cin>>pStd->name; 
cout<<"请输入学生的座号"<<endl; 
cin>>pStd->num; 
cout<<"请输入学生的语文分数"<<endl; 
cin>>pStd->chinaNum; 
cout<<"请输入学生的数学分数"<<endl; 
cin>>pStd->mathNum; 
cout<<"请输入学生的英语分数"<<endl; 
cin>>pStd->englishNum; 
} 
else 
{ 
return ; 
} 
} 

void Sort(student *&head, char type,char maxOrMin) 
{ 
/*参数说明: 
type=='1' 按 语文 排列 
type=='2' 按 数学 排列 
type=='3' 按 英语 排列 
type=='4' 按 总分 排列 
type=='5' 按 平均分 排列 
type=='6' 按 座号 排列 
*/ 
student *pHead,*pH; 
pHead=pH=head; 
int len=GetLength(head); 
float *array=new float[len]; 
int i; 
int x=0; 

float num=0; 

while(head) 
{ 
Count(head); 
if(type=='1') 
{ 
num=head->chinaNum; 
} 
else if(type=='2') 
{ 
num=head->mathNum; 
} 
else if(type=='3') 
{ 
num=head->englishNum; 
} 
else if(type=='4') 
{ 
num=head->result; 
} 
else if(type=='5') 
{ 

num=head->average; 
} 
else if(type=='6') 
{ 
num=head->num; 
} 
array[x]=num; 
x++; 
head=head->next; 
} 

head=pHead; 
if(maxOrMin=='1') 
{ 
for( i=1; i<len; i++) 
{ 
for(int j=0; j<len-i; j++) 
{ 
if(array[j]<array[j+1]) 
{ 
float num; 
num=array[j]; 
array[j]=array[j+1]; 
array[j+1]=num; 
} 
} 
} 
} 
else 
{ 
for( i=1; i<len; i++) 
{ 
for(int j=0; j<len-i; j++) 
{ 
if(array[j]>array[j+1]) 
{ 
float num; 
num=array[j]; 
array[j]=array[j+1]; 
array[j+1]=num; 
} 
} 
} 
} 

int pos=1; 

for(i=0; i<len; i++) 
{ 
head=pHead; 
while(head) 
{ 
if(type=='1') 
{ 
num=head->chinaNum; 
} 
else if(type=='2') 
{ 
num=head->mathNum; 
} 
else if(type=='3') 
{ 
num=head->englishNum; 
} 
else if(type=='4') 
{ 
num=int(head->result); 
} 
else if(type=='5') 
{ 
num=int(head->average); 
} 
else if(type=='6') 
{ 
num=int(head->num); 
} 

int n=0; 
if(int(array[i])==int(num)) 
{ 

if(int(array[i])!=int(array[i+1])) 
{ 
if(n==0) 
{ 
n=pos; 
} 
head->pos=pos; 
pos++; 
} 
else 
{ 

head->pos=n; 
} 
} 
head=head->next; 
} 
} 
head=pH; 
delete []array; 
} 

void Count(student *&head) 
{ 
head->result=head->chinaNum+head->englishNum+head->mathNum; 
head->average=head->result/3; 
} 

void DeleteAll(student* &head) 
{ 
student *cp,*np; 

cp=head; 
while(cp) 
{ 
np=cp->next; 
delete cp; 
cp=np; 
} 
head=NULL; 
} 

void ChaXun(string str,student *head) 
{ 
Sort(head,'4','1'); 
cout<<"欢迎使用查询功能"<<endl<<endl; 
cout<<"请输入你要按什么查询 1->一般查询 2->查找最多 3->查找最少"<<endl; 
string s; 
cin>>s; 
while(s[0]!='1'&&s[0]!='2'&&s[0]!='3') 
{ 
cout<<"你输入错误,请重新输入."<<endl; 
cin>>s; 
} 

if(s[0]=='1') 
{ 
cout<<"按什么查询?"<<endl; 
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 " 
<<"5->英语成绩 6->总分 7->平均分 8->排名"<<endl; 
cin>>str; 

while(str[0]!='1' && str[0]!='2' && 
str[0]!='3' && str[0]!='4' && 
str[0]!='5' && str[0]!='6' && 
str[0]!='7' && str[0]!='8' ) 
{ 
cout<<"你输入错误,请重新输入."<<endl; 
cin>>str; 
} 
char findStr[30]; 
cout<<"请输入要查找的关键字或关键数:"<<endl; 
cin>>findStr; 
switch(str[0]) 
{ 

case '1': 
Find(head,findStr,'1'); 
break; 
case '2': 
Find(head,findStr,'2'); 
break; 
case '3': 
Find(head,findStr,'3'); 
break; 
case '4': 
Find(head,findStr,'4'); 
break; 
case '5': 
Find(head,findStr,'5'); 
break; 
case '6': 
Find(head,findStr,'6'); 
break; 
case '7': 
Find(head,findStr,'7'); 
break; 
case '8': 
Find(head,findStr,'8'); 
break; 
} 
} 
else if(s[0]=='2') 
{ 
cout<<"请输入要按什么查询?"<<endl; 
cout<<"1->语文成绩 2->数学成绩 " 
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl; 
string s; 
cin>>s; 
switch(s[0]) 
{ 
case '1': 
FindMaxOrMin(head,'1','1'); 
break; 
case '2': 
FindMaxOrMin(head,'2','1'); 
break; 
case '3': 
FindMaxOrMin(head,'3','1'); 
break; 
case '6': 
FindMaxOrMin(head,'6','1'); 
break; 
case '5': 
FindMaxOrMin(head,'5','1'); 
break; 
default: 
FindMaxOrMin(head,'4','1'); 
break; 
} 
} 
else if(s[0]=='3') 
{ 
cout<<"请输入要按什么查询?"<<endl; 
cout<<"1->语文成绩 2->数学成绩 " 
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl; 
string s; 
cin>>s; 
switch(s[0]) 
{ 
case '1': 
FindMaxOrMin(head,'1','2'); 
break; 
case '2': 
FindMaxOrMin(head,'2','2'); 
break; 
case '3': 
FindMaxOrMin(head,'3','2'); 
break; 
case '6': 
FindMaxOrMin(head,'6','2'); 
break; 
case '5': 
FindMaxOrMin(head,'5','2'); 
break; 
default: 
FindMaxOrMin(head,'4','2'); 
break; 
} 
} 
} 
void ZengJia(string str, student* &head) 
{ 
student *pNew=new student; 
cout<<"欢迎使用增加功能"<<endl<<endl; 
cout<<"请输入新学生的名字 :"<<endl; 
cin>>pNew->name; 
cout<<"请输入新学生的座号 :"<<endl; 
cin>>pNew->num; 
cout<<"请输入他的语文分数 :"<<endl; 
cin>>pNew->chinaNum; 
cout<<"请输入他的数学分数"<<endl; 
cin>>pNew->mathNum; 
cout<<"请输入他的英语分数"<<endl; 
cin>>pNew->englishNum; 

cout<<"插入记录的 (1->最前面 2->最后面)"<<endl; 
cin>>str; 
while(str[0]!='1' && str[0]!='2') 
{ 
cout<<"你输入错误,请重新输入."<<endl; 
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl; 
cin>>str; 
} 
if(str[0]=='1') 
{ 
InsertFront(head,pNew); 
} 
else if(str[0]=='2') 
{ 
InsertRear(head,pNew); 
} 
cout<<"新学生增加成功."<<endl; 

} 

void ShanChu(string str, student *&head) 
{ 
char delStr[30]; 
cout<<"欢迎使用删除功能"<<endl<<endl; 
cout<<"1->查询删除 2->全部删除"<<endl; 
cin>>str; 
while(str[0]!='1' && str[0]!='2') 
{ 
cout<<"输入错误,请重新输入."<<endl; 
cin>>str; 
} 
if(str[0]=='1') 
{ 
cout<<"请输入要删除的关键字"<<endl; 
cin>>delStr; 
cout<<"1->删除第一条找到的记录 2->删除所有找到的记录"<<endl; 
cin>>str; 
while(str[0]!='1'&&str[0]!='2') 
{ 
cout<<"你输入错误,请重新输入."<<endl; 
cin>>str; 
} 
cout<<"你真的要删除吗? 1->删除 2->取消"<<endl; 
string s; 
cin>>s; 
if(str[0]=='1') 
{ 
if(str[0]=='1') 
{ 
Delete(head,delStr,1); 

} 
else 
{ 
Delete(head,delStr,2); 
} 
} 
else 
{ 
cout<<"你已经取消删除了."<<endl; 
} 
} 
else 
{ 
cout<<"你真的要删除全部数据吗?这样会使你的数据全部丢失哦."<<endl; 
cout<<"1->全部删除 2->取消删除"<<endl; 
cin>>str; 
if(str[0]=='1') 
{ 
DeleteAll(head); 
} 
else 
{ 
cout<<"你已经取消删除了."<<endl; 
} 
} 


} 

void PaiMing(string str, student* head) 
{ 
string s; 
cout<<"欢迎使用排名功能"<<endl<<endl; 
cout<<"排名选择: 1->升序 2->降序"<<endl; 
cin>>s; 
cout<<"请输入要按什么排名?"<<endl; 
cout<<"1->语文成绩 2->数学成绩 3->英语成绩 " 
<<"4->总分 5->平均分 6->座号"<<endl; 

cin>>str; 

while(str[0]!='1' && str[0]!='2' && 
str[0]!='3' && str[0]!='4' && 
str[0]!='5' && str[0]!='6' ) 
{ 
cout<<"你输入错误,请重新输入."<<endl; 
cin>>str; 
} 
cout<<"姓名:"<<setw(8)<<"座号:"<<setw(10) 
<<"语文分数:"<<setw(10) <<"数学分数:" 
<<setw(10)<<"英语分数:"<<setw(8)<<"总分数:" 
<<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl; 
if(s[0]=='2') 
{ 
switch(str[0]) 
{ 

case '1': 
Sort(head,'1','1'); 
break; 
case '2': 
Sort(head,'2','1'); 
break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -