学生成绩分析系统

#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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值