8 条题解

  • 4
    @ 2024-4-4 10:49:07

    这才是Python最简代码 print(input()[::-1])

    • 2
      @ 2024-1-20 15:32:56

      全网最简代码(Python)

      a = input()
      print(a[2]+a[1]+a[0])
      
      • 1
        @ 2023-8-6 8:32:13
        #include <bits/stdc++.h>
        using namespace std;
        int main(){
            char a, b, c;
            cin >> a >> b >> c;
            cout << c << b << a;
        }
        
        • 1
          @ 2023-7-1 22:18:38

          说实话,把它分成单独的,倒置过来不就行了...

          #include<iostream>
          using namespace std;
          int main()
          {
              char q,a,z;
              cin>>q>>a>>z;
              cout<<z<<a<<q;
              return 0;
          }
          
          • 1
            @ 2023-5-23 1:10:01
            #include<iostream>
            using namespace std;
            int main() {
                int x;
                int a, b, c;
                cin>>x;
                a=x/100;//百位
                b=x/10%10;//十位
                c=x%10;//个位
                cout<<c<<b<<a;//反向输出
                return 0;
            }
            
            • 1
              @ 2023-5-22 15:35:34

              思路1:取位输出

              难点 :题目表示给定的是一个3位数字,清楚知道每一位的对应取位方式。

              对应取位方式

              n%10//取出个位,例如321%10=1
              n/10%10//取出十位,例如321/10=32%10=2
              n/100//取出百位,例如321/100=3
              

              参考代码

              #include <iostream>
              using namespace std;
              int main(){
                   int n;
                   cin>>n;//输入三位数
                   cout<<n%10;//求出个位,输出
                   cout<<n/10%10;//求出十位,输出
                   cout<<n/100;//求出百位,输出
                   return 0;
              }
              

              思路2:while 循环数位拆分

              通过拆位舍位实现数字倒序输出(所有数字通用)

              难点while 循环条件,拆位以及舍位的过程

              模板代码

              while(n>0){
                      n%10;
                      n=n/10;
                  }
              

              例子321的拆位过程

              1. 321%10=1 取到个位数字1 , n = 321/10=32舍弃已经取出的个位数字

              2. 32%10=2取到此时的个位数字2, n = 32/10=3舍弃已经取出的个位数字

              3. 3%10=3取到此时的个位数字3, n = 3/10=0舍弃已经取出的个位数字

                注:所有数字舍位最后都会舍弃到0 ,到0也就意味着取位已经取完了可以结束循环

              参考代码

              #include <iostream>
              using namespace std;
              int main(){
                  int n;
                  cin>>n;//输入这个数字
                  while(n>0){
                      cout<<n%10;//输出每次取出来的个位数
                      n=n/10;//舍弃个位
                  }
                  return 0;
              }
              
              • 1
                @ 2023-5-21 15:33:50

                思路 个十百三位位置上数字保持不变,仅仅是改变个位十位百位上的数字的位置输出。

                知识点 987%100表示987除以100的余数,为87; 87/10表示87除10的整数,为8;

                易漏点 scanf与&(易漏写)搭配使用; int main()与return对应; int main()的 括号易漏 代码

                #include<stdio.h>
                int main()
                {
                	int n,n1,n2,n3;
                	scanf("%d",&n);
                	n1=n/100;
                	n2=n%100/10;
                	n3=n%10;
                	printf("%d%d%d",n3,n2,n1);
                	return 0; 
                }```
                
                • 0
                  @ 2024-4-13 22:12:58
                  #include <iostream>
                  using namespace std;
                  int main()
                  {
                      int n,x,y,z;
                      cin >> n;
                      x = n / 100;//得到百位
                      y = n / 10 %10;//得到十位
                      z = n % 10;//得到个位
                      cout << z << y << x;//倒序输出
                      return 0;
                  }
                  
                  • 1

                  信息

                  ID
                  97
                  时间
                  1000ms
                  内存
                  256MiB
                  难度
                  3
                  标签
                  递交数
                  304
                  已通过
                  162
                  上传者