lzy13915136909 @ 2024-05-23 19:22:30
code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T,s=0;
cin>>T;
if (T == 1)
{
cout << "I love Luogu!";
return 0;
}
else if (T == 2)
{
cout<<2+4<<" "<<10-2-4;
return 0;
}
else if (T == 3)
{
int a=14/4;
cout<<a<<endl;
cout<<a*4<<endl;
cout<<14-a*4<<endl;
return 0;
}
else if (T == 4)
{
double b;
b=500/3;
printf("%.3f",b);
return 0;
}
else if (T == 5)
{
cout<<(260+220)/(20+12);
}
else if (T == 6)
{
cout<<sqrt(6*6+9*9)<<endl;
return 0;
}
else if (T == 7)
{
cout<<100+10<<endl;
cout<<100+10-20<<endl;
cout<<"0"<<endl;
return 0;
}
else if (T == 8)
{
cout<<(5+5)*3.141593<<endl;
return 0;
}
else if (T == 9)
{
cout<<((((1+1)*2+1)*2)+1)*2;
return 0;
}
else if (T == 10)
{
cout<<9<<endl;
return 0;
}
else if (T == 11)
{
cout<<1.0*100/3;
return 0;
}
else if (T == 12)
{
cout<<(int)('M'-'A')+1<<endl<<(char)(18+'A'-1);
return 0;
}
else if (T == 13)
{
int r1=4,r2=10;
double pi=3.141593;
double v=4.0/3*pi*r1*r1*r1+4.0/3*pi*r2*r2*r2;
v=pow(v,1.0/3);
printf("%.0lf\n",v);
return 0;
}
else if (T == 14)
{
cout<<"50"<<endl;
return 0;
}
return 0;
}
by kexun_kevin @ 2024-05-23 19:33:06
T 等于 4 的时候不能用 int/int 否则仍为 int 类型,改为 500.0/3 即可。T 等于 8 时少输出了两个答案,代码如下:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int T,s=0;
cin>>T;
if (T == 1)
{
cout << "I love Luogu!";
return 0;
}
else if (T == 2)
{
cout<<2+4<<" "<<10-2-4;
return 0;
}
else if (T == 3)
{
int a=14/4;
cout<<a<<endl;
cout<<a*4<<endl;
cout<<14-a*4<<endl;
return 0;
}
else if (T == 4)
{
double b;
b=500.0/3;
printf("%.3f",b);
return 0;
}
else if (T == 5)
{
cout<<(260+220)/(20+12);
}
else if (T == 6)
{
cout<<sqrt(6*6+9*9)<<endl;
return 0;
}
else if (T == 7)
{
cout<<100+10<<endl;
cout<<100+10-20<<endl;
cout<<"0"<<endl;
return 0;
}
else if (T == 8)
{
cout<<(5+5)*3.141593<<endl<<(5*5)*3.141593<<endl<<4.0/3*(5*5*5)*3.141593<<endl;
return 0;
}
else if (T == 9)
{
cout<<((((1+1)*2+1)*2)+1)*2;
return 0;
}
else if (T == 10)
{
cout<<9<<endl;
return 0;
}
else if (T == 11)
{
cout<<1.0*100/3;
return 0;
}
else if (T == 12)
{
cout<<(int)('M'-'A')+1<<endl<<(char)(18+'A'-1);
return 0;
}
else if (T == 13)
{
int r1=4,r2=10;
double pi=3.141593;
double v=4.0/3*pi*r1*r1*r1+4.0/3*pi*r2*r2*r2;
v=pow(v,1.0/3);
printf("%.0lf\n",v);
return 0;
}
else if (T == 14)
{
cout<<"50"<<endl;
return 0;
}
return 0;
}
by kexun_kevin @ 2024-05-23 19:33:33
@lzy13915136909
by lzy13915136909 @ 2024-05-23 19:55:32
@kexun_kevin AC啦,求壶关