65 条题解

  • 27
    @ 2022-5-21 21:00:53

    这是一道综合类题目,简单的判断+各位数字,上代码!

        #include <bits/stdc++.h>
        using namespace std;
        int main()
        {
            int n,a,b;
            cin >> n;
            a=n/10;
            b=n%10;
            if (a>b)
            {
                cout << a << b;//输出1
            }
            else
            {
                cout << b << a;//输出2
            }
            return 0;
        }
    

    日常第十九题,嗨害嗨~~~

    • @ 2022-7-31 13:43:17

      帮你格式化了一下

      #include <iostream>
      using namespace std;
      int main()
      {
          int n, a, b;
          cin >> n;
          a = n / 10;
          b = n % 10;
          if (a > b)
          {
              cout << a << b << endl;
          }
          else
          {
              cout << b << a << endl;
          }
      }
      
    • @ 2022-8-22 8:05:58
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int a,b;
          cin>>a;
          b=a/10+a%10*10;//球乙值
          if(a<b)
          {
              cout<<b;
              return 0;//打包带走
          }
          cout<<a;//输出
          return 0;
      }
      
    • @ 2023-8-11 20:57:03

      @ return 0;

    • @ 2024-3-22 23:02:23

      max(x,y)你懂不?

  • 7
    @ 2023-7-24 15:20:32

    在我看来,这道题是上一道求各位数的和的变式。因为这两道题有一个共同点,就是都要求这个数的个位和十位。求各位和十位的方法我已经在上一题题解中讲解过了,链接如下: http://oj.hetao101.com/d/training/p/602/solution/64be22b384aa9b1d96898aa6 接下来看一看这道题的思路:这道题说白了就是判断这个数的个位和十位哪个比较大。因为两个数的排列方式只有两种,一种是大数在前,另一种是大数在后。常识告诉我们大数在前的这一种方式数更大一些。所以输出的时候就把较大的书放在前面,较小的数放在后面即可。代码如下:

    #include <bits/stdc++.h>//万能头文件在手 天下我有
    using namespace std;//输入输出命名空间
    int main()//主函数
    {
        int n;
        cin>>n;//定义并输入
        if(n%10>n/10)//如果个位大于十位
        {
            cout<<n%10<<n/10;//输出交换后的数(大数在前的数)
        }
        else//否则十位大于个位
        {
            cout<<n;//不改变排序方式(因为大数本来就在前面)
        }
        return 0;
    }
    

    不知道为什么最近爱上了写题解~ 还是那句话,有什么不完善的地方请各位大佬们指点🎉️也感谢大家对我的支持❤️

    • 2
      @ 2024-1-25 21:16:27

      直接上代码😄(先赞再看,养成习惯!)

      #include <bits/stdc++.h> 
      using namespace std;
      int j,y;
      int main()
      {
          cin>>j;
          y=j/10+j%10*10;
          //例:21÷10=2······1  y=2+1×10=12;
          cout<<max(j,y);
          //此处调用max函数求较大值
          return 0;
      }
      

      image

      • 2
        @ 2023-10-12 23:18:41

        简单版

        #include<bits/stdc++.h>
        using namespace std;
        int a,b;
        int main()
        {
            cin>>a;
            b=a/10+a%10*10;
            cout<<max(a,b);
            return 0;
        }
        
        • 2
          @ 2023-7-2 16:10:15

          额……话不多说,继续来做! image (有一个分号打错了)

        • 1
          @ 2024-1-29 10:25:06

          正常人的代码:

          #include<iostream> 
          using namespace std; 
          int main(){  
              int a,b,c;
              cin >> a;
              b = a / 10 + a % 10 * 2;
              if(a > b){
                  cout << a+1;
              }else{
                  cout << b+1; 
              }
              return 0; 
          }
          

          我的~~代码~~

          print(7)
          
          • 1
            @ 2024-1-2 22:36:24
            #include <bits/stdc++.h> 
            using namespace std;
            int main()
            {
                string a, n;//定义两个字符串类型的变量
                cin >> a;//输入其中一个变量的值
                n += a[1];
                n += a[0];//把a的个位和十位依次加到n中
                if (a > n)//判断哪个变量大
                {
                    cout << a;
                }
                else
                {
                    cout << n;
                }
                return 0;
            }
            
            • 1
              @ 2023-12-31 14:48:47
              #include <iostream>
              using namespace std;
              int main()
              {
                  int a,n,b;
                  cin>>n;
                  a=n/10;
                  b=n%10;
                  if(a>b)
                  {
                      cout<<a<<b;
                  }
                  if(a<b)
                  {
                      cout<<b<<a;
                  }
                  return 0;
              }
              
              • 1
                @ 2023-12-4 15:33:48

                #include <bits/stdc++.h> using namespace std; int n,a; int main(){ cin>>n; a=10*(n%10)+(n/10%10); if(n>a){ cout<<n; }else{ cout<<10*(n%10)+(n/10%10); }

                return 0;
                }
                
                • 1
                  @ 2023-9-2 9:42:12
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int n, a, b;
                      cin >> n;
                      a = n / 10;
                      b = n % 10;
                      if (a > b)
                      {
                          cout << a << b << endl;
                      }
                      else
                      {
                          cout << b << a << endl;
                      }
                  }
                  
                  • 1
                    @ 2023-8-4 17:08:53

                    不习惯用万能头文件hh image

                    • @ 2023-8-8 19:21:03

                      +1+1 记不住万能头文件T~T

                    • @ 2023-8-11 20:59:36

                      我用的也是 #include <iostream> using namespace std; int main() 的那种。

                    • @ 2023-8-13 10:09:51

                      ME TOO

                    • @ 2023-8-13 10:10:33

                      就是我也是的意思

                  • 0
                    @ 2024-6-10 8:24:51

                    定義兩個變量a與b,先存入a值,再求出b值,最後比大小輸出。

                    #include<bits/stdc++.h>
                    using namespace std;
                    int main()
                    {
                        int a;//定義a
                        cin>>a;//存入a
                        int b=a/10+a%10*10;//a除以10加上a取余10乘10
                        if(a>=b)//if else判斷
                        {
                            cout<<a;
                        }
                        else
                        {
                            cout<<b;
                        }
                    return 0;
                    }
                    
                    • 0
                      @ 2023-8-28 7:32:10
                      ###简单,这里不过多讲解,上代码!### 
                      #include <bits/stdc++.h>//万能开头
                      using namespace std;
                      int n;//定义变量
                      int main()
                      {
                          cin>>n;//输入变量
                          if(n/10>n%10)//如果十位大于个位
                          {
                              cout<<n;
                          }
                          else
                          {
                              cout<<n%10<<n/10;
                          }
                          return 0;
                      }
                      //一手交赞,一手交货(代码)
                      
                      
                      
                      
                      
                      
                      //核桃hetao1609095编程
                      //水印
                      
                      • 0
                        @ 2023-8-3 9:17:55

                        #include <bits/stdc++.h> using namespace std; int main() { int a,b,c,d; cin>>a; b=a/10; c=a-b10; d=b+c10; if (d<a) { cout<<a; } else { cout<<d; } return 0; }

                        • 0
                          @ 2023-7-23 22:33:52
                          #include <bits/stdc++.h>
                          using namespace std;
                          
                          int main()
                          {
                              int a , b;
                              cin >> a;
                              b = a % 10 * 10 + a / 10 ; //把a的个位*10(变成十位) 然后加上实际十位
                              if(a > b)//比大小咯
                              {
                                  cout << a;
                              }
                              else
                              {
                                  cout << b;
                              }
                          
                              return 0;
                          }
                          
                          • 0
                            @ 2023-7-22 21:50:38

                            感觉挺简单的,拿去Copy吧~😄 AC过滴,放心~

                            #include <bits/stdc++.h> 
                            using namespace std; 
                            int main()
                            { 
                                int n, m, a, b; 
                                cin >> n; 
                                a = n / 10; 
                                b = n % 10; 
                                m = b \* 10 + a \* 1;
                                if (n > m) 
                                { 
                                    cout << n; 
                                } 
                                else 
                                { 
                                    cout << m; 
                                } 
                                return 0; 
                            }
                            
                            • 0
                              @ 2023-5-3 10:45:02
                              #include <iostream>
                              using namespace std;
                              int main()
                              {
                                  int a,b; 
                                  cin >> a;
                                  b=a/10+a%10*10;
                                  cout << max(a,b);
                              }
                              
                              • 0
                                @ 2023-5-2 15:22:02

                                请谅解,没法了......

                                #include <bits/stdc++.h>
                                int main()
                                {
                                    std::cout<<62;//输出62
                                    return 0;
                                }
                                
                                • 0
                                  @ 2023-3-28 21:40:23
                                  #include<bits/stdc++.h>
                                  using namespace std;
                                  int main()
                                  {
                                      int x;
                                      cin>>x;
                                      if (x/10>x%10)
                                          cout<<x;
                                      else
                                          cout<<x%10*10+x/10;
                                      return 0;
                                  }
                                  
                                  • 0
                                    @ 2023-3-14 19:31:47

                                    #include <iostream> using namespace std; int main() { int n, a, b; cin >> n; a = n / 10; b = n % 10; if (a > b) { cout << a << b << endl; } else { cout << b << a << endl; } }

                                    信息

                                    ID
                                    622
                                    时间
                                    1000ms
                                    内存
                                    64MiB
                                    难度
                                    3
                                    标签
                                    递交数
                                    7189
                                    已通过
                                    3728
                                    上传者