POJ 2070 Filling Out the Team(我的水题之路——double比较)

Filling Out the Team
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 8371   Accepted: 4626

Description

Over the years, the people of the great city of Pittsburgh have repeatedly demonstrated a collective expertise at football second to none. Recently a spy has discovered the true source of the city's football power-a wizard known only as "Myron," who is infallible at selecting the proper position at which each player will excel. 

Now that you know the source of Pittsburgh's wisdom, you are determined to provide your school's football team with a computer program that matches the wisdom of "Myron." You have consulted with the best football minds you can find, and they have dispensed their wisdom on the slowest speed, minimum weight, and minimum strength required to play each position. 

Using this knowledge, you will develop a program that reads in several players physical attributes and outputs what position(s) they are able to play.

Input

Each line of the input file will list the attributes for one player: 
< speed > < weight > < strength > 
Each number will be a real-valued number. The file will end with a line reading "0 0 0"

Output

For each player, you will output one line listing the positions that player can play. A player can play a position if each of their attributes is greater or equal to the minimum for weight and strength, and less than or equal to the slowest speed. If a player can play multiple positions, output them in the order listed above, separated by whitespace. You may leave an extra space at the end of the line. If a player can play no positions, write "No positions" on the line.

Sample Input

4.4 180 200
5.5 350 700
4.4 205 350
5.2 210 500
0 0 0

Sample Output

Wide Receiver
Lineman
Wide Receiver Quarterback
No positions

Source

Mid-Atlantic 2004

对于每一行的三个数据,第一个数据需要小于等于speed,第二三个数据需要大于等于weight、strength,这样就输出这个位置的英文名。

注意点:
1)输出的所有位子的英文名后面要加一个空格。
2)float、double的比较可以直接用>=/<=/</>/==/!=比较,不要用speed[i] - x >= 0.000001.导致1WA。

代码(1AC 1WA):
#include <cstdio>
#include <cstdlib>

char str[3][50] = {"Wide Receiver", "Lineman", "Quarterback"};
double speed[3] = {4.5, 6.0, 5.0};
int weight[3] = {150, 300, 200};
int strength[3] = {200, 500, 300};

int main(void){
    double x;
    int y, z;
    int i, flag = 0;

    while (scanf("%lf%d%d", &x, &y, &z), x != 0.0 || y != 0 || z != 0){
        flag = 0;
        for (i = 0; i < 3; i++){
            if (speed[i] >= x){
                if (weight[i] <= y && strength[i] <= z){
                    printf("%s ", str[i]);
                    flag = 1;
                }
            }
        }
        if (flag == 0){
            printf("No positions");
        }
        printf("\n");
    }
    return 0;
}


你可能感兴趣的:(File,input,each,attributes,output,wizard)