POJ2070 Filling Out the Team

老套的题,想要把代码写的非常简单还得花很多功夫,我是利用了flag变量作为标志来进行判断的,实际上也是写了很多的代码 - -

很简单吧,没啥值得一提的,附代码

#include 
using namespace std;
int main(){
    int we,st;
    float sp;
    while(cin>>sp>>we>>st&&sp*we*st!=0){
        int flag1=0,flag2=0,flag3=0;
        if(sp<=4.5&&we>=150&&st>=200) flag1=1;
        if(sp<=6.0&&we>=300&&st>=500) flag2=1;
        if(sp<=5.0&&we>=200&&st>=300) flag3=1;
        if(flag1){
            if(flag2){
                if(flag3){
                    cout<<"Wide Receiver Lineman Quarterback"<else cout<<"Wide Receiver Lineman"<else{
                if(flag3){
                    cout<<"Wide Receiver Quarterback"<else cout<<"Wide Receiver"<else{
            if(flag2){
                if(flag3){
                    cout<<"Lineman Quarterback"<else cout<<"Lineman"<else{
                if(flag3){
                    cout<<"Quarterback"<else cout<<"No positions"<return 0;
}

你可能感兴趣的:(POJ解题,各大OJ刷题系列)