15 条题解
-
10
这一道题可以结合 Level 4 所有的倒叙题目,来看看吧~
- 首先,这道题没有给我们到底有几位数,所以用 while 语句来写循环
- 每一次将新的值 b 变成 b * 10(如4 * 10 = 40,空出个位数)+ a % 10(个位数)
- 每一次记得也将 a 的各位去掉哦:a /= 10
- 最后写 while 结束的条件 a > 0 时执行代码,否则跳出
- 最后输出即可啦~
来吧,用完美结束 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; }
-
2
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
我们可以用字符串的思想解这道题。 首先判断输入数字末尾有几个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]; }
如此即可。
-
-2
#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; }
- 1
信息
- ID
- 121
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 2
- 标签
- 递交数
- 752
- 已通过
- 437
- 上传者