zoj 2321 Filling Out the Team

//没有仔细的阅读题目,以致在比较的时候漏掉了等于的情况!
#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;
		}
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值