关闭

zoj 2321 Filling Out the Team

311人阅读 评论(0) 收藏 举报
//没有仔细的阅读题目,以致在比较的时候漏掉了等于的情况!
#include "iostream"
#include "string"
#include "vector"
using namespace std;

struct Info
{
	string pos;
	double speed;
	int weight;
	int strength;
};

int main()
{
	int weight, strength, i, size;
	double speed;
	vector<Info> v;
	vector<Info> ans;
	Info info[3];
	info[0].pos = "Wide Receiver", info[0].speed = 4.5, info[0].weight = 150, info[0].strength = 200;
	v.push_back(info[0]);
	info[1].pos = "Lineman", info[1].speed = 6.0, info[1].weight = 300, info[1].strength = 500;
	v.push_back(info[1]);
	info[2].pos = "Quarterback", info[2].speed = 5.0, info[2].weight = 200, info[2].strength = 300;
	v.push_back(info[2]);

	while (cin >> speed >> weight >> strength && speed && weight && strength)
	{
		ans.clear();
		for (i = 0; i < 3; i++)
		{
			if (v[i].speed >= speed && v[i].weight <= weight && v[i].strength <= strength)
				ans.push_back(v[i]);
		}
		size = ans.size();
		if (size == 0)
			cout << "No positions" << endl;
		else
		{
			for (i = 0; i < size; i++)
			{
				if (i != 0)
					cout << " ";
				cout << ans[i].pos;
			}
			cout << endl;
		}
	}
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:486817次
    • 积分:8058
    • 等级:
    • 排名:第2509名
    • 原创:414篇
    • 转载:22篇
    • 译文:0篇
    • 评论:55条
    最新评论