15 条题解

  • 10
    @ 2022-8-16 21:26:14

    这一道题可以结合 Level 4 所有的倒叙题目,来看看吧~

    1. 首先,这道题没有给我们到底有几位数,所以用 while 语句来写循环
    2. 每一次将新的值 b 变成 b * 10(如4 * 10 = 40,空出个位数)+ a % 10(个位数)
    3. 每一次记得也将 a 的各位去掉哦:a /= 10
    4. 最后写 while 结束的条件 a > 0 时执行代码,否则跳出
    5. 最后输出即可啦~

    来吧,用完美结束 Level 4 的学习,谢谢啦~(AC过,不用讲了吧)

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int a, b = 0;
        cin >> a;
        while (a > 0)
        {
            b = b * 10 + a % 10;
            a /= 10;
        }
        cout << b;
    	return 0;
    }
    
    • @ 2023-12-9 12:02:32
      #include<bits/stdc++.h>
      using namespace std;
      int a[9999];
      int main(){
      	char s[9999];
      	scanf("%s",s+1);
      	int l=strlen(s+1);
      	for(int i=1;i<=l;i++){
      		a[i]=s[i]-'0';
      	}
      	while(a[l]==0){
      		l--;
      	}
      	for(int i=l;i>=1;i--){
      		cout<<a[i];
      	}
      	return 0;
      }
      
  • 4
    @ 2024-1-20 11:52:17

    兄弟们啊,来呀,吃屎呀! 知识就是力量,吃屎就是欲望! 满足欲望难道有什么不好的吗? 来呀,吃屎呀!

    已AC,请放心食用

    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        while (n > 0)
        {
            if (n % 10 != 0)
            {
                cout << n % 10;
            }
            n /= 10;
        }
    }
    

    给俺,点赞,再走呗~

    • 2
      @ 2023-8-4 20:29:42

      L2小萌新预习完来练手啦

      思路:字符串倒序输出,跳过0(不过bug是如果0在中间就不好用了👀️ ,V10大大的代码真的好用👍 )

      好啦上代码🚀️

      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          string a;
          cin >> a;
          for (int i = a.length() - 1;i >= 0; i--) 
          {
              if (a[i] != '0') cout << a[i];
          }
          return 0;
      }
      

      L4大部分在讲字符和字符串,所以我就用字符串解吧(有bug,不过AC,放心食用)

      • 0
        @ 2023-11-20 15:00:50

        1、将数字以字符形式运行。 2、将字符串逆序遍历,找到第一个非’0‘字符的索引。 3、从找到的索引依次输出逆序后的字符。

        n = input()
        temp = 0
        for i in n[::-1]:
            if i != '0':
                temp = n[::-1].index(i)
                break
        print(n[temp::-1])
        
        • 0
          @ 2023-7-22 13:32:17
          #include <cstdio>
          using namespace std;
          int main(){
              int n,x=0;
              scanf("%d",&n);
              while(n>0)x=x*10+n%10,n/=10;
              printf("%d\n",x);
              return 0;
          }
          
          • 0
            @ 2023-7-6 8:40:36

            除去直接输出 345345,这个代码应该最短了

            #include <bits/stdc++.h>
            using namespace std;
            string s;
            int main(){
                //记得将编译器改成C++14
                cin>>s;
                reverse(s.begin(),s.end());
                cout<<stoi(s);
                //只消3行
                return 0;
            }
            
            • 0
              @ 2023-2-21 19:02:33

              用字符串更好

              • 0
                @ 2022-12-17 20:57:37
                #include <bits/stdc++.h>
                using namespace std;
                int x,y;
                int main()
                {
                    cin>>x;
                    while(x)
                    {
                        y=y*10+x%10;
                        x/=10;
                    }
                    cout<<y;
                    return 0;
                }
                

                简单~

                • 0
                  @ 2022-8-18 21:26:44

                  我们可以用字符串的思想解这道题。 首先判断输入数字末尾有几个0:

                  int n=s.length(),num=0;
                      for(int i=n-1;i>=0;i--)
                      {
                      	if(s[i]=='0')//统计0的个数
                      	{
                      		num++;
                      		continue;
                      	}
                      	else break;//如果s[i]不等于0,就说明剩下的0不需要跳过,所以直接跳出循环
                      }
                  

                  然后直接反向输出字符串,跳过末尾的0:

                  for(int i=n-1;i>=0;i--)
                      {
                          if(s[i]=='0'&&num>=0)//末尾0的个数已经固定,所以跳过对应个数的0
                  		{
                              n--;
                  			continue;
                  		}
                          cout<<s[i];
                      }
                  

                  如此即可。

                  • 0
                    @ 2022-8-2 18:05:10
                    如果要是更易懂一点可以这样:
                        int n;
                        cin >> n;
                        while (n % 10 == 0)
                        {
                            n /= 10;
                        }
                        while (n > 0)
                        {
                            cout << n % 10;
                            n /= 10;
                        }
                    两个while循环
                    八月的第四个题解!!!
                    
                    • 0
                      @ 2022-5-26 19:48:32

                      简单的数位拆分,拆完合成一个新数就好啦~

                      
                          while(n)
                          {
                          	m = m*10+n%10;
                          	n/=10;
                      	}
                      
                      
                      • -1
                        @ 2022-12-3 20:10:56
                        #include <bits/stdc++.h>
                        using namespace std;
                        int main(){
                            cout<<345;
                            return 0;
                        }
                        

                        啊这

                      • -2
                        @ 2023-7-8 12:53:56

                        #include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }#include <iostream> #include <cmath> using namespace std; int produce(int& n) { int num = 0; int sum = 0; for (int i = 1; n / i != 0; i *= 10) { if (n / i != 0) { num++; } } for (int i = 1; i < num; i++) { sum += (n - n / (int)pow(10, i) * (int)pow(10, i)) / (int)pow(10, i - 1) * (int)pow(10, num - i); } sum += n / pow(10, num - 1); n = sum; return n; } int main() { int n; cin >> n; cout << produce(n); return 0; }

                        • -2
                          @ 2022-8-22 18:13:10

                          回文数:多谢官方~

                          • -2
                            @ 2022-8-18 16:15:06

                            #include <iostream> using namespace std; int main() { int a=0; int b=0; cin>>a; while(n>0)其实就是求余数 { b=b*10+a%10; a/=10; } cout<<b; return 0; }

                            • 1

                            信息

                            ID
                            121
                            时间
                            1000ms
                            内存
                            64MiB
                            难度
                            2
                            标签
                            递交数
                            752
                            已通过
                            437
                            上传者