22 条题解

  • 3
    @ 2023-6-16 13:12:48

    解析

    输入一个数,判断这个数是不是十位数。

    十位数是指大于等于10且小于等于99的数。

    题解

    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        if (n >= 10 && n <= 99)
        {
            cout << 1;
        }
        else
        {
            cout << 0;
        }
        return 0;
    }
    
    • 1
      @ 2024-6-5 20:19:42

      题解 c++

      #include <bits/stdc++.h> //hetao4040809
      using namespace std;
      int main()
      {
          float n;
          cin>>n;
          if(n>=10&&n<100)
          {
              cout<<1;
          }
          else 
          {
              cout<<0;
          }
          return 0;
      }
      
      • 1
        @ 2024-4-20 14:59:46
        #include<iostream>
        using namespace std;
        int main()
        {
            int n;
            cin>>n;
            if(n>9&&n<100)
            {
                cout<<1;
            }
            else
            {
                cout<<0;
            }
            return 0;
        }
        
        • 1
          @ 2024-4-12 22:40:30

          可能和别人代码有点重复(声明:不是抄袭,自己写的),但是就是不想用if (太麻烦啦,对懒癌患者不太友好) 言归正传,不要抄袭,尽量自己理解~

          #include <iostream>
          using namespace std;
          int main()
          {
             int n;
             cin >> n;
             cout << ((n>=10)&&(n<=99)?1:0);
             return 0;
          }
          
          • 0
            @ 2024-6-1 14:28:15
            #include <iostream>
            using namespace std;
            int main()
            {
                int a;
                cin>>a;
                if(a>=10 and a<=99) cout<<1;
                else cout<<0;
                return 0;
            }
            
            
            
            • 0
              @ 2024-5-24 17:11:15
              #include<iostream>
              #include<cstdio>
              #include<cmath>
              #include<iomanip>
              using namespace std;
              int main()
              {
                  int a;
                  cin >> a;
                  if (a > 9  && a < 100)
                      cout << 1;
                  else
                      cout << 0;
                  return 0;
              }
              
              • 0
                @ 2024-4-9 15:58:33
                #include <iostream>
                #include <iomanip>
                #include <cstdio>
                #include <cmath>
                using namespace std;
                int main()
                {
                    long long a;//创建a
                    cin >> a;//输入一个数
                    if (a>9 && a<100)//这里偷了个懒
                    {
                        cout << "1";//输出
                    }
                    else
                    {
                        cout << "0";//输出
                    }
                    return 0;
                }
                //(自己看题解学的(给个赞吧!!
                
                • 0
                  @ 2024-4-6 20:36:52
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int a;//定义a
                      cin >> a;//导入
                      if (a >= 10 and a <= 99)//判断a是否在二位数的范围内
                      {
                          cout << "1";
                      }
                      else
                      {
                          cout << "0";
                      }
                      return 0;
                  }
                  
                  
                  
                  • 0
                    @ 2024-2-1 17:32:51
                    #include<bits/stdc++.h>
                    using namespace std;
                    int main()
                    {
                        int n;
                        cin>>n;
                        if(n>9&&n<100)cout<<1;
                        else cout<<0;
                    }
                    
                    
                    • 0
                      @ 2023-6-23 16:40:25

                      字符串

                      #include <bits/stdc++.h>
                      using namespace std;
                      int main()
                      {
                          string a;
                          cin >> a;
                          if (a.length() == 2)
                          {
                              cout << 1;
                              return 0;
                          }
                          cout << 0;
                          return 0;
                      }
                      
                      • 0
                        @ 2023-6-17 22:36:17

                        判断是否为两位数

                        思路:

                        按常规思路,判断一个数是否为两位数,我们(py转过来的)一般用字符串长度,8

                        但是这里是C++!我们还没学……所以不能用字符串长度,不按常规的思路,思考一下,两位数的范围是几到几,10 ~ 99,so you will be like them……,输入的数字的范围就是10 <= 输入的数 <= 99 tips:在程序中不能这么写,要用&&,即10 <= 输入的数 && 输入的数 <= 99

                        参考代码

                        #include <iostream>
                        using namespace std;
                        int main() {
                            int a;
                            cin >> a;
                            if (10 <= a && a <= 99) {
                                cout << 1;
                            }
                            else {
                                cout << 0;
                            }
                            return 0;
                        }
                        
                        • 0
                          @ 2023-6-17 16:47:46

                          发题解的这么少,我也来发一个:

                          #include <iostream>
                          using namespace std;
                          int main()
                          {
                              int n;
                              cin >> n;
                              n >= 10 && n <= 99 ? cout << 1 : cout << 0;
                              return 0;
                          }
                          

                          只要数字大于等于10 且小于等于99 就代表是两位数。用三目运算符 效果与 if -else 一样。 有错误请指出哦!🎉️ 点个赞呗👍 ~

                          • -1
                            @ 2023-11-5 17:07:23

                            1.循环

                            #include <bits/stdc++.h> 
                            using namespace std;
                            int main()
                            {
                                int n, num = 0;
                                cin >> n;
                                while(n > 0)
                                {
                                    num++;
                                    n /= 10;
                                }
                                if(num == 2)
                                {
                                    cout << "1";
                                    return 0;
                                }
                                    cout << "0";
                                return 0;
                            }
                            

                            2.if判断

                            #include <iostream>
                            using namespace std;
                            int main()
                            {
                            int n;
                            cin >> n;
                            if(n >= 10 && n <= 99)
                            {
                            cout << 1;
                            }
                            else
                            {
                            cout << 0;
                            }
                            return 0;
                            }
                            

                            3.字符串

                            #include <bits/stdc++.h>
                            using namespace std;
                            int main()
                            {
                                string s;
                                cin >> s;
                                if(s.length() == 2)
                                {
                                    cout << 1;
                                }
                                else
                                {
                                    cout << 0;
                                }
                                return 0;
                            }
                            
                            • -1
                              @ 2023-10-15 9:26:40
                              思路

                              没有脑子的我突然暴起想到了一个有史以来最复杂代码(就是对蒟蒻不友好怎么了

                              daima
                              #include <bits/stdc++.h>
                              using namespace std;
                              int n;
                              bool check(int x)
                              {
                                  if(x>=10)
                                      if(x<99)  return 1;
                                  return 0;
                              }
                              int main()
                              {
                                  scanf("%d",%n);
                                  if(check(n+1) or check(n-1)  cout<<"1";
                                  else  cout<<"0";
                                  return 0;
                              }
                              

                              😄

                              • -1
                                @ 2023-7-27 19:15:46
                                #include<iostream>
                                using namespace std;
                                int main()
                                {
                                    int n;
                                    cin >> n;
                                    if (n >= 10 && n <= 99)
                                    {
                                    cout << "1";
                                    }
                                    else
                                    {
                                    cout << "0";
                                    }
                                    return 0;
                                }
                                
                                • -1
                                  @ 2023-7-7 21:17:50
                                  #include <iostream>
                                  #include <cstdio>
                                  #include <cmath>
                                  using namespace std;
                                  int main()
                                  {
                                      int a,b;
                                      cin>>a>>b;
                                      if (a<60 && b>=60 || a>=60 && b<60)
                                          cout<<1;
                                      else
                                          cout<<0;
                                      return 0;
                                  }
                                  
                                  • -1
                                    @ 2023-7-7 19:51:20

                                    解析

                                    输入一个数,判断这个数是不是十位数。

                                    十位数是指大于等于10且小于等于99的数。😄 😄

                                    #include <iostream>
                                    using namespace std;
                                    
                                    int main()
                                    {
                                        int a;
                                       cin >> a;
                                        if (a >= 10 && a <= 99)
                                          cout << 1;
                                       else
                                          cout << 0;
                                       return 0; 
                                    }
                                    
                                    • -1
                                      @ 2023-6-24 15:40:37
                                      #include <iostream>
                                      #include <cstdio>
                                      #include <cmath>
                                      using namespace std;
                                      int main()
                                      {
                                          int a;
                                          cin>>a;
                                          cout<<(a>9&&a<100);
                                          return 0;
                                      }
                                      

                                      (其实不应该在这张里)

                                      • -1
                                        @ 2023-6-17 15:58:25
                                        #include <iostream>
                                        using namespace std;
                                        int main()
                                        {
                                            int a;
                                            cin >> a;
                                            if (a >= 10 && a <= 99)
                                                cout << "1";
                                            else
                                                cout << "0";
                                            return 0;
                                        }
                                        

                                        解析: 判断是否大于等于10且小于等于99,符合要求的都是两位数。 你也可以不用判断语句,直接输出:

                                        (a >= 10 && a <= 99) (别打引号成字符串了)

                                        因为在输出时会自动判断,是即输出1,否即0,恰好符合题目要求。

                                        • -1
                                          @ 2023-6-17 12:48:31
                                          #include <iostream>
                                          using namespace std;
                                          
                                          int main()
                                          {
                                              int n;//因为输入的整数小于1000,所以int是够用的
                                              cin >> n;
                                              if (9 < n && n < 100)//判断这个数是不是两位数,也可以写为10 <= n && n <= 99
                                                  cout << 1;
                                              else
                                                  cout << 0;
                                              return 0;
                                          }
                                          

                                          信息

                                          ID
                                          148
                                          时间
                                          1000ms
                                          内存
                                          128MiB
                                          难度
                                          3
                                          标签
                                          递交数
                                          1908
                                          已通过
                                          1026
                                          上传者