jsdhwdmaxZYJ @ 2023-09-01 22:47:04
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
switch(a){
case 1:cout<<"I Love Luogu!"<<endl;
case 2:cout<<2+4<<" "<<10-2-4<<endl;break;
case 3:cout<<14/4<<endl<<14/4*4<<endl<<14-14/4*4<<endl;break;
case 4:cout<<fixed<<setprecision(3)<<1.0*500/3<<endl;break;
case 5:cout<<(260+220)/(12+20)<<endl;break;
case 6:cout<<sqrt(6*6+9*9)<<endl;break;
case 7:cout<<110<<endl<<90<<endl<<0<<endl;break;
case 8:double r=5;break;
const double PI=3.1415923;
cout<<2*PI*r<<endl;
cout<<PI*r*r<<endl;
cout<<4.0/3*PI*pow(r,3)<<endl;
case 9:cout<<(((1+1)*2+1)*2+1)*2<<endl;break;
case 10:int n1=8,t1=30,n2=10,t2=6;break;
int t3=10;
double inc_rate=(1.0*n1*t1-n2*t2)/(t1-t2);
double init_num=n2*t2-inc_rate*t2;
double ans=(init_num+t3*inc_rate)/t3;
cout<<ans;
case 11:cout<<1.0*100/3<<endl;break;
case 12:cout<<(int)('M'-'A')+1<<endl<<(char)(18+'A'-1);break;
case 13:cout<<(int)(pow(4/3*pi*(4*4*4+10*10*10),1.0*1/3))<<endl;break;
case 14:cout<<50<<endl;break;
}
return 0;
}
by ZJle @ 2023-09-01 22:49:00
@jsdhwdmaxZYJ PI 大小写问题
by jsdhwdmaxZYJ @ 2023-09-01 22:51:03
@Lj_zjl0 谢谢!
by dthythxth_Huge_Brain @ 2023-09-01 22:51:13
@jsdhwdmaxZYJ 你的每一个 case 都要加个括号
by jsdhwdmaxZYJ @ 2023-09-01 22:53:41
@Lj_zjl0 可是改了还是不行。
by ZJle @ 2023-09-01 22:55:30
@jsdhwdmaxZYJ
help.cpp: In function 'int main()':
help.cpp:19:14: error: jump to case label
19 | case 9:cout<<(((1+1)*2+1)*2+1)*2<<endl;break;
| ^
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:20:14: error: jump to case label
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:26:14: error: jump to case label
26 | case 11:cout<<1.0*100/3<<endl;break;
| ^~
help.cpp:24:16: note: crosses initialization of 'double ans'
24 | double ans=(init_num+t3*inc_rate)/t3;
| ^~~
help.cpp:23:16: note: crosses initialization of 'double init_num'
23 | double init_num=n2*t2-inc_rate*t2;
| ^~~~~~~~
help.cpp:22:16: note: crosses initialization of 'double inc_rate'
22 | double inc_rate=(1.0*n1*t1-n2*t2)/(t1-t2);
| ^~~~~~~~
help.cpp:21:13: note: crosses initialization of 'int t3'
21 | int t3=10;
| ^~
help.cpp:20:38: note: crosses initialization of 'int t2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:32: note: crosses initialization of 'int n2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:26: note: crosses initialization of 'int t1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:21: note: crosses initialization of 'int n1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:27:14: error: jump to case label
27 | case 12:cout<<(int)('M'-'A')+1<<endl<<(char)(18+'A'-1);break;
| ^~
help.cpp:24:16: note: crosses initialization of 'double ans'
24 | double ans=(init_num+t3*inc_rate)/t3;
| ^~~
help.cpp:23:16: note: crosses initialization of 'double init_num'
23 | double init_num=n2*t2-inc_rate*t2;
| ^~~~~~~~
help.cpp:22:16: note: crosses initialization of 'double inc_rate'
22 | double inc_rate=(1.0*n1*t1-n2*t2)/(t1-t2);
| ^~~~~~~~
help.cpp:21:13: note: crosses initialization of 'int t3'
21 | int t3=10;
| ^~
help.cpp:20:38: note: crosses initialization of 'int t2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:32: note: crosses initialization of 'int n2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:26: note: crosses initialization of 'int t1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:21: note: crosses initialization of 'int n1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:28:14: error: jump to case label
28 | case 13:cout<<(int)(pow(4/3*PI*(4*4*4+10*10*10),1.0*1/3))<<endl;break;
| ^~
help.cpp:24:16: note: crosses initialization of 'double ans'
24 | double ans=(init_num+t3*inc_rate)/t3;
| ^~~
help.cpp:23:16: note: crosses initialization of 'double init_num'
23 | double init_num=n2*t2-inc_rate*t2;
| ^~~~~~~~
help.cpp:22:16: note: crosses initialization of 'double inc_rate'
22 | double inc_rate=(1.0*n1*t1-n2*t2)/(t1-t2);
| ^~~~~~~~
help.cpp:21:13: note: crosses initialization of 'int t3'
21 | int t3=10;
| ^~
help.cpp:20:38: note: crosses initialization of 'int t2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:32: note: crosses initialization of 'int n2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:26: note: crosses initialization of 'int t1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:21: note: crosses initialization of 'int n1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:29:14: error: jump to case label
29 | case 14:cout<<50<<endl;break;
| ^~
help.cpp:24:16: note: crosses initialization of 'double ans'
24 | double ans=(init_num+t3*inc_rate)/t3;
| ^~~
help.cpp:23:16: note: crosses initialization of 'double init_num'
23 | double init_num=n2*t2-inc_rate*t2;
| ^~~~~~~~
help.cpp:22:16: note: crosses initialization of 'double inc_rate'
22 | double inc_rate=(1.0*n1*t1-n2*t2)/(t1-t2);
| ^~~~~~~~
help.cpp:21:13: note: crosses initialization of 'int t3'
21 | int t3=10;
| ^~
help.cpp:20:38: note: crosses initialization of 'int t2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:32: note: crosses initialization of 'int n2'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:26: note: crosses initialization of 'int t1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:20:21: note: crosses initialization of 'int n1'
20 | case 10:int n1=8,t1=30,n2=10,t2=6;break;
| ^~
help.cpp:15:22: note: crosses initialization of 'const double PI'
15 | const double PI=3.1415923;
| ^~
help.cpp:14:23: note: crosses initialization of 'double r'
14 | case 8:double r=5;break;
| ^
help.cpp:7:39: warning: this statement may fall through [-Wimplicit-fallthrough=]
7 | case 1:cout<<"I Love Luogu!"<<endl;
| ^~~~
help.cpp:8:9: note: here
8 | case 2:cout<<2+4<<" "<<10-2-4<<endl;break;
| ^~~~
by jsdhwdmaxZYJ @ 2023-09-01 23:04:15
@Lj_zjl0 感谢!!
by TianKeHan @ 2023-09-02 19:25:57
大佬牛蛙
by wsxzzy @ 2023-09-03 11:45:43
大,大,大,大佬?!
by lxl2012 @ 2023-10-15 15:50:26
case 1:后没写break