1 条题解

  • 0
    @ 2026-1-23 20:21:57
    #include<bits/stdc++.h>
    using namespace std;
    
    int main() {
        int n;  // [1] n-输入的5位正整数
        cin>>n;  // [2] 读取这个5位正整数n
        
        int g=n%10;  // [3] g-提取n的个位数字(对10取余得到)
        int s=n/10%10;  // [4] s-提取n的十位数字(除以10去除个位后,对10取余)
        int b=n/10/10%10;  // [5] b-提取n的百位数字(连续除以10两次去除个位、十位后,对10取余)
        cout<<g*100+s*10+b;  // [6] 数字重新组合
        return 0;                  
    }
    
    • 1

    输入一个三位数,把个位和百位对调后输出

    信息

    ID
    1092
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    1
    已通过
    1
    上传者