#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
bool flag = false;
int main()
{
string name[50], find_name;
string exchange_name;
int n, i, j, num[50];
float score[50], temp;
int k;
cout << "please input the numbers of student:" << endl;
cin >> n;
cout << "please input the name ,NO. and their score:" << endl;
for (i = 0; i < n; i++)
{
cout << "student" << i + 1 << ":";
cin >> name+ >> num+ >> score+;
}
if (score+ > 100 || num+ < 0)
cout << "data error!" << endl;
for(j=0;j<n-1;j++)
for(i=0;i<n-j;i++)
if (score+ < score[i + 1])
{
temp = score+;
score+ = score[i + 1];
score[i + 1] = temp;
k = num+;
num+ = num[i + 1];
num[i + 1] = k;
exchange_name = name+;
name+ = name[i + 1];
name[i + 1] = exchange_name;
}
cout << "there are grade and their score:" << endl;
cout << "name " << " number " << "score" << " ranking" << endl;
for (i = 0; i < n; i++)
{
cout <<" "<< name+ << setw(6) << num+ << setw(6) << score+ <<setw(6)<< i + 1 << endl;
}
cout << "there are the student who not pass " << endl;
cout << "name " << " number " << "score" << " ranking" << endl;
for (i = 0; i < n; i++)
{
if (score+ < 60)
{
cout << name+ << setw(5) << num+ << setw(5) << score+ << setw(5) << i + 1 << endl;
}
}
cout << "the grade of have pass the exam" << endl;
for(i=0;i<n;i++)
{
if (score+ ==100)
{
cout << name+ << "'s grade is" << " king" << endl;
}
else if (score+ >=90)
{
cout << name+ << "'s grade is" <<'A' << endl;
}
else if (score+ >= 80)
{
cout << name+ << "'s grade is" << 'B' << endl;
}
else if (score+ >= 70)
{
cout << name+ << "'s grade is" << 'C' << endl;
}
else if (score+ >= 60)
{
cout << name+ << "'s grade is" << 'D' << endl;
}
}
cout << "please input the name who you want find:";
cin >> find_name;
for (i = 0; i < n; i++)
if (find_name == name+)
{
flag == true;
cout << name+ <<'\t' <<"number is"<< num+ <<'\t' <<"score is"<< score+ << endl;
break;
}
if (flag == false)
cout << "Can't find this name" << endl;
cout<<endl;
system("pause");
return 0;
}