52 条题解

  • 0
    @ 2022-8-21 19:58:34

    这道题确实看着让人不由自主的地想狂写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
      @ 2022-8-21 14:46:02
      #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
        @ 2022-7-16 17:44:32

        int n; cin>>n; if (n<100000) { cout<<"wan" ; } else { if (n<1000000) { cout<<"shi wan"; } else { if (n<10000000) { cout<<"bai wan"; } else { if (n<10000000) { cout<<"qian wan"; } else { if (n<1000000000) { cout<<"yi"; } else { cout<<"shi yi"; } } } } } return 0; }

        • 0
          @ 2022-5-22 19:15:05

          使用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
            @ 2023-12-29 18:52:46

            #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
              @ 2023-8-11 10:55:05
              #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
                @ 2023-8-8 9:51:53
                #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
                  @ 2023-7-14 19:50:21
                  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
                    @ 2023-3-29 6:56:43
                    #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
                      @ 2023-2-10 10:42:55

                      好简单 #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; }

                      • @ 2023-8-26 17:30:28

                        除非手不酸,那才叫简单~

                    • -1
                      @ 2023-1-7 18:14:11
                      #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;
                          }
                      }
                      
                      • -1
                        @ 2022-9-16 21:23:58
                        #include <iostream>
                        using namespace std;
                        string a[12]={" "," "," "," ","wan","shi wan","bai wan","qian wan","yi","shi yi"};
                        int main()
                        {
                            string s;
                            cin>>s;
                            int len=s.size();
                            cout<<a[len-1];
                            return 0;
                        }
                        

                        信息

                        ID
                        319
                        时间
                        1000ms
                        内存
                        16MiB
                        难度
                        3
                        标签
                        递交数
                        4873
                        已通过
                        2630
                        上传者