52 条题解
-
0
这道题确实看着让人不由自主的地想狂写if语句,但是,大可不必。 因为上限9999999999=10^10*9.9,下限10000=10^5,所以只需要判断字符串string类型长度的大小即可,精华部分如下:
string a; #定义字符串类型 a int p=0; cin>>a; p=a.length();/*求字符串长度, 也可以用strlen和size替代*/ }
下面部分建议用switch语句判断,毕竟if语句的可读性出了名的不行。 注意: ****string类型的代码在cstring里(如果是万能的头文件,当我没说)!
-
0
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; if (n > 999999999) { cout << "shi yi"; } else if (n > 99999999) { cout << "yi"; } else if (n > 9999999) { cout << "qian wan"; } else if (n > 999999) { cout << "bai wan"; } else if (n > 99999) { cout << "shi wan"; } else if (n > 9999) { cout << "wan"; } return 0; }
-
0
使用if...else if...else语句,判断区间,输出对应的字符串就可以啦
if(n>=10000&&n<100000){ cout<<"wan"; }else if(n>=100000&&n<1000000){ cout<<"shi wan"; }else if(n>=1000000&&n<10000000){ cout<<"bai wan"; }else if(n>=10000000&&n<100000000){ cout<<"qian wan"; }else if(n>=100000000&&n<1000000000){ cout<<"yi"; }else{ cout<<"shi yi"; }
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if(n >= 10000 and n < 99999) { cout << "wan" << endl; } if(n >= 100000 and n < 999999) { cout << "shi wan" << endl; } if(n >= 1000000 and n < 9999999) { cout << "bai wan" << endl; } if(n >= 10000000 and n < 99999999) { cout << "qian wan" << endl; } if(n >= 100000000 and n < 999999999) { cout << "yi" << endl; } if(n >= 1000000000 and n < 9999999999) { cout << "shi yi" << endl; } return 0; }
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n >= 1000000000) { cout << "shi yi"; } else if (n >= 100000000) { cout << "yi"; } else if (n >= 10000000) { cout << "qian wan"; } else if (n >= 1000000) { cout << "bai wan"; } else if (n >= 100000) { cout << "shi wan"; } else { cout << "wan"; } return 0; }
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if(n >= 10000 and n < 99999) { cout << "wan" << endl; } if(n >= 100000 and n < 999999) { cout << "shi wan" << endl; } if(n >= 1000000 and n < 9999999) { cout << "bai wan" << endl; } if(n >= 10000000 and n < 99999999) { cout << "qian wan" << endl; } if(n >= 100000000 and n < 999999999) { cout << "yi" << endl; } if(n >= 1000000000 and n < 9999999999) { cout << "shi yi" << endl; } return 0; }
代码不好编写,记得点赞
-
-1
int n; cin >> n; if(n<=99999) { cout<<"wan"; } if(n<=999999)if(n>=100000) { cout<<"shi wan"; } if(n<=9999999)if(n>=1000000) { cout<<"bai wan"; } if(n<=99999999)if(n>=10000000) { cout<<"qian wan"; } if(n<=999999999)if(n>=100000000) { cout<<"yi"; } if(n<=9999999999)if(n>=1000000000) { cout<<"shi yi"; }
-
-1
#include<bits/stdc++.h> using namespace std; int main() { long long n; cin>>n; if (n/1000000000>0) cout<<"shi yi"; else if (n/100000000>0) cout<<"yi"; else if (n/10000000>0) cout<<"qian wan"; else if (n/1000000>0) cout<<"bai wan"; else if (n/100000>0) cout<<"shi wan"; else cout<<"wan"; return 0; }
-
-1
好简单 #include <iostream> using namespace std; int main() { long long n; cin>>n; if(n>=1000000000) { cout<<"shi yi"; } else if(n>=100000000) { cout<<"yi"; } else if(n>=10000000) { cout<<"qian wan"; } else if(n>=1000000) { cout<<"bai wan"; } else if(n>=100000) { cout<<"shi wan"; } else { cout<<"wan"; } return 0; }
-
-1
#include <iostream> using namespace std; int main() { int n; cin>>n; if( n>10000 && n<=99999 ) { cout << "wan"; return 0; } else if(n>100000 && n<=999999) { cout << "shi wan"; return 0; } else if(n>1000000 && n<=9999999) { cout << "bai wan"; return 0; } else if(n>10000000 && n<=99999999) { cout << "qian wan"; return 0; } else if(n>100000000 && n<=999999999) { cout << "yi"; return 0; } else if(n>1000000000 && n<=9999999999) { cout << "shi yi"; return 0; } }
信息
- ID
- 319
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 3
- 标签
- 递交数
- 4873
- 已通过
- 2630
- 上传者