怎么说,帮我康康,原本A过,再做一遍又WA了两个点,我发现12后面不能测试诶

P2433 【深基1-2】小学数学 N 合一

ganaa @ 2020-05-17 09:11:11

#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
double PI=3.1415923;
int main()
{
    int T;
    cin>>T;
    if(T==1)
    {
        cout<<"I love Luogu!"<<endl;
    }
    else if(T==2)
    {
        cout<<2+4<<" "<<10-2-4<<endl;
    }
    else if(T==3)
    {
        cout<<"3"<<endl;
        cout<<"12"<<endl;
        cout<<"2"<<endl;
    }
    else if(T==4)
    {
        cout<<fixed<<setprecision(3)<<1.0*500/3<<endl;
    }
    else if(T==5)
    {
        cout<<(260+220)/(12+20)<<endl;
    }
    else if(T==6)
    {
        cout<<sqrt(6*6+9*9)<<endl;
    }
    else if(T==7)
    {
        cout<<110<<endl;
        cout<<90<<endl;
        cout<<0;
    }
    else if(T==8)
    {
            cout<<PI*10<<endl;
            cout<<PI*25<<endl;
            cout<<4*PI*125/3.0<<endl;
    }
    else if(T==9)
    {
        cout<<(((((1+1)*2)+1)*2)+1)*2<<endl;
    }
    else if(T==10)
    {
        cout<<9<<endl;
    }
    else if(T==11)
    {
        cout<<100/(8.0-5.0)<<endl;
    }
    else if(T=12)
    {
        cout<<13<<endl<<'R'<<endl;
    }
    else if(T==13)
    {
        cout<<16<<endl;
    }
    else if(T==14)
    {
        for(int i=1;i<=110;i++)
        {
            int s=120-i;
            int ans=s*i;
            if(ans==3500) 
            {
               cout<<i<<endl;
            }
        }
    }
}

by ganaa @ 2020-05-17 09:49:07

@Garrosh ?


by 迷失再黑夜里 @ 2020-06-03 17:11:37

@ytyangmingxuan

else if(T==14)
    {
        for(int i=1;i<=110;i++)
        {
            int s=120-i;
            int ans=s*i;
            if(ans==3500) 
            {
               cout<<i<<endl;
               break;
            }
        }
    }

加个break


by FarrisL @ 2020-06-10 12:24:04

@ytyangmingxuan

 else if(T=12)//你告诉我这是什么?
    {
        cout<<13<<endl<<'R'<<endl;
    }

by ganaa @ 2020-06-10 12:50:19

@FarrisL 哦哦,谢谢


by FarrisL @ 2020-06-11 12:36:30

@ytyangmingxuan 不客气


by weimoshuai888 @ 2020-06-13 20:20:39

else if(T ==12) { cout<<13<<endl<<'R'<<endl; }


|