sicily 1818.成绩转换

解题策略:用map可以实现映射,并对相同元素更新!

#include 
#include 
#include 
using namespace std;

int main()
{
	int caseNum;
	cin >> caseNum;
	while(caseNum--)
	{
		int m,n;
		cin >> n >> m;
		map maps;
		string name = "";
		int score = 0;
		while(n--)
		{
			cin >> name >> score;
			maps[name] = score;
		}

		while(m--)
		{
			cin >> name;
			if(maps[name] > 100 || maps[name] < 0)
				cout << "Score is error!" << endl;
			else if(maps[name] < 60)
				cout << "E" << endl;
			else if(maps[name] < 70)
				cout << "D" << endl;
			else if(maps[name] < 80)
				cout << "C" << endl;
			else if(maps[name] < 90)
				cout << "B" << endl;
			else if(maps[name] <= 100)
				cout << "A" << endl;
		}
	}
	
	return 0;
}


你可能感兴趣的:(ACM,个人笔记,c++)