SZ2528 @ 2020-05-10 21:15:30
代码:
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
switch(n) {
case 1:
cout<<"I love Luogu!"<<endl;
break;
case 2:
cout<<2+4<<" "<<10-2-4<<endl;
break;
case 3:
cout<<int(14/4)<<" "<<" "<<14-int(14/4)*4<<endl;
break;
case 4:
printf("%.3lf",500.0/3);
break;
case 5:
cout<<(260+220)/(12+20)<<endl;
break;
case 6:
cout<<sqrt(6*6+9*9)<<endl;
break;
case 7:
cout<<100+10<<" "<<100+10-20<<" "<<0<<endl;
break;
case 8:
cout<<5*1.0*2*3.141593<<" "<<3.141593*5*5<<" "<<4.0/3*3.141593*3*3*3<<endl;
break;
case 9:
int n=4,peach=1;
for(int i=0; i<n-1; i++) {
peach++;
peach*=2;
}
cout<<peach<<endl;
break;
case 10:
cout<<9<<endl;
break;
case 11:
cout<<100*1.0/(5+8)<<endl;
break;
case 12:
cout<<int('M'-'A'+1)<<endl<<char('A'-1+18)<<endl;
break;
case 13:
cout<<pow((4.0/3*3.141593*4*4*4)+(4.0/3*3.141593*10*10*10),1.0/3)<<endl;
break;
case 14:
cout<<50<<endl;
break;
}
return 0;
}
by AKIOI官方账号 @ 2020-05-10 21:16:47
窝看看
by Mine_King @ 2020-05-10 21:17:49
编译信息?
by Veranda @ 2020-05-10 21:18:02
窝也看看记得某大佬说过用else if更好
by AKIOI官方账号 @ 2020-05-10 21:20:32
@wYYSZL王屹峰 按照道理来说这不会失败的
by zhjxaoini @ 2020-05-10 21:23:18
@wYYSZL王屹峰 ???这就不是问题啊,变量名冲突时使用内部变量
by AKIOI官方账号 @ 2020-05-10 21:23:25
话说case好像不支持定义变量。
by TensorFlow_js @ 2020-05-10 21:23:40
cstdio呢 头文件
by zhjxaoini @ 2020-05-10 21:23:44
还有 pow
也没问题啊
by AKIOI官方账号 @ 2020-05-10 21:24:05
@zhaojinxi switch好像不支持定义变量。。。
by zhjxaoini @ 2020-05-10 21:24:24
@SZ棋 CE 是因为 switch
本来就不能定义局部变量