#include<iostream>
#include<cstdlib>
using namespace std;
#include<stdlib.h>
void input();
void find();
void find1();
void find2();
void find21();
void find22();
void sumaver();
void maxmin();
void quit();
const int n=5;
int *score;
int main()
{new int [n];
p=new int[n];
int x;
if(score==NULL){
cout<<"申请动态空间失败!\n";
return 0;}
while(1)
{do
{ cout<<" *****************************"<<endl;
cout<<" 欢迎使用学生成绩系统,请输入相应的数字来选择您的操作"<<endl;
cout<<" *****************************"<<endl;
cout<<" 1:录入学生成绩"<<endl;
cout<<" 2:查找学生成绩"<<endl;
cout<<" 3:求总分和平均成绩"<<endl;
cout<<" 4:求最高分和最低分"<<endl;
cout<<" 5:退出本系统"<<endl;
cin>>x;}while(x<1||x>5);
switch(x)
{case 1:input();break;
case 2:find();break;
case 3:sumaver();break;
case 4:maxmin();break;
case 5:quit();
}
}
delete []score;}
void input()
{ system("cls");
cout<<"请依次输入成绩:"<<endl;
for(int i=0;i<n;i++)
{cout<<i+1<<"号:";
cin>>score[i];}
cout<<"成绩输入完毕."<<endl;
}
void find()
{ system("cls");
int x;
do
cout<<"请选择"1"或"2":"<<endl;
cout<<"1:精确查找"<<endl;
cout<<"2:模糊查找"<<endl;
cin>>x;}
while(x!=1&&x!=2);
switch(x)
{case 1:find1();break;
case 2:find2();
}
}
void find1()
{system("cls");
cout<<"请输入要查找的分数:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(s==score[i])cout<<"第"<<i+1<<"个同学的分数是"<<s<<endl;
cout<<endl;
}
void find2()
{system("cls");
int x;
do
{cout<<"请选择:"<<endl;
cout<<"1:按最高分查找"<<endl;
cout<<"2:按最低分查找"<<endl;
cin>>x;}while(x!=1&&x!=2);
switch(x)
{case 1:find21();break;
case 2:find22();
}
}
void find21()
{system("cls");
cout<<"请输入要查找的最高分:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(score[i]<=s)cout<<"第"<<i+1<<"号 ";
cout<<"的分数低于或等于"<<s<<endl;
}
void find22()
{system("cls");
cout<<"请输入要查找的最低分:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(score[i]>=s)cout<<"第"<<i+1<<"号 ";
cout<<"的分数高于或等于"<<s<<endl;
}
void sumaver()
{system("cls");
int sum=0;
for(int i=0;i<n;i++)
sum+=score[i];
cout<<"全班总分是:"<<sum<<endl;
cout<<"全班平均分是:"<<sum/n<<endl;
}
void maxmin()
{system("cls");
int max=score[0],min=score[0];
for(int i=1;i<n;i++)
{ if(score[i]>max) max=score[i];
if(score[i]<min)min=score[i];
}
cout<<"全班最高分是:"<<max<<endl;
cout<<"全班最低分是:"<<min<<endl;
}
void quit()
{ system("cls");
cout<<" *************************************"<<endl;
cout<<" 欢迎再次使用本系统!"<<endl;
cout<<" 再见!"<<endl;
cout<<" *************************************"<<endl;
exit(0);
}
#include<cstdlib>
using namespace std;
#include<stdlib.h>
void input();
void find();
void find1();
void find2();
void find21();
void find22();
void sumaver();
void maxmin();
void quit();
const int n=5;
int *score;
int main()
{new int [n];
p=new int[n];
int x;
if(score==NULL){
cout<<"申请动态空间失败!\n";
return 0;}
while(1)
{do
{ cout<<" *****************************"<<endl;
cout<<" 欢迎使用学生成绩系统,请输入相应的数字来选择您的操作"<<endl;
cout<<" *****************************"<<endl;
cout<<" 1:录入学生成绩"<<endl;
cout<<" 2:查找学生成绩"<<endl;
cout<<" 3:求总分和平均成绩"<<endl;
cout<<" 4:求最高分和最低分"<<endl;
cout<<" 5:退出本系统"<<endl;
cin>>x;}while(x<1||x>5);
switch(x)
{case 1:input();break;
case 2:find();break;
case 3:sumaver();break;
case 4:maxmin();break;
case 5:quit();
}
}
delete []score;}
void input()
{ system("cls");
cout<<"请依次输入成绩:"<<endl;
for(int i=0;i<n;i++)
{cout<<i+1<<"号:";
cin>>score[i];}
cout<<"成绩输入完毕."<<endl;
}
void find()
{ system("cls");
int x;
do
cout<<"请选择"1"或"2":"<<endl;
cout<<"1:精确查找"<<endl;
cout<<"2:模糊查找"<<endl;
cin>>x;}
while(x!=1&&x!=2);
switch(x)
{case 1:find1();break;
case 2:find2();
}
}
void find1()
{system("cls");
cout<<"请输入要查找的分数:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(s==score[i])cout<<"第"<<i+1<<"个同学的分数是"<<s<<endl;
cout<<endl;
}
void find2()
{system("cls");
int x;
do
{cout<<"请选择:"<<endl;
cout<<"1:按最高分查找"<<endl;
cout<<"2:按最低分查找"<<endl;
cin>>x;}while(x!=1&&x!=2);
switch(x)
{case 1:find21();break;
case 2:find22();
}
}
void find21()
{system("cls");
cout<<"请输入要查找的最高分:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(score[i]<=s)cout<<"第"<<i+1<<"号 ";
cout<<"的分数低于或等于"<<s<<endl;
}
void find22()
{system("cls");
cout<<"请输入要查找的最低分:"<<endl;
int s;
cin>>s;
for(int i=0;i<n;i++)
if(score[i]>=s)cout<<"第"<<i+1<<"号 ";
cout<<"的分数高于或等于"<<s<<endl;
}
void sumaver()
{system("cls");
int sum=0;
for(int i=0;i<n;i++)
sum+=score[i];
cout<<"全班总分是:"<<sum<<endl;
cout<<"全班平均分是:"<<sum/n<<endl;
}
void maxmin()
{system("cls");
int max=score[0],min=score[0];
for(int i=1;i<n;i++)
{ if(score[i]>max) max=score[i];
if(score[i]<min)min=score[i];
}
cout<<"全班最高分是:"<<max<<endl;
cout<<"全班最低分是:"<<min<<endl;
}
void quit()
{ system("cls");
cout<<" *************************************"<<endl;
cout<<" 欢迎再次使用本系统!"<<endl;
cout<<" 再见!"<<endl;
cout<<" *************************************"<<endl;
exit(0);
}