首页 > 专题系列 > Java解POJ > POJ 2070 Filling Out the Team [解题报告] Java
2013
11-10

POJ 2070 Filling Out the Team [解题报告] Java

Filling Out the Team

问题描述 :

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.

输入:

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″

输出:

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.

样例输入:

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

样例输出:

Wide Receiver
Lineman
Wide Receiver Quarterback
No positions

解题代码:

//* @author: [email protected]
import java.util.Scanner;
public class Main
{
 public static void main(String[] args)
 {
  Scanner in=new Scanner(System.in);
  while(in.hasNext())
  {
   float a=in.nextFloat();
   float b=in.nextFloat();
   float c=in.nextFloat();
   if(a==0&&b==0&&c==0) break;
   boolean s=true;
   if(a<=4.5&&b>=150&&c>=200){
     System.out.print("Wide Receiver ");
     s=false;
    }
   if(a<=6&&b>=300&&c>=500){
     System.out.print("Lineman ");
     s=false;
   }

   if(a<=5&&b>=200&&c>=300){
     System.out.print("Quarterback ");
     s=false;
    }
   if(s) System.out.print("No positions");
   System.out.println();
   }
 }
}

  1. 第一句可以忽略不计了吧。从第二句开始分析,说明这个花色下的所有牌都会在其它里面出现,那么还剩下♠️和♦️。第三句,可以排除2和7,因为在两种花色里有。现在是第四句,因为♠️还剩下多个,只有是♦️B才能知道答案。

  2. I go through some of your put up and I uncovered a good deal of expertise from it. Many thanks for posting this sort of exciting posts