You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
630 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
cin >> n;
//特判
if (n == 0) {
printf("0");
exit(0);
}
//如果是负数,输出负号
if (n < 0) n = -n, printf("-");
//数位分离
bool flag = false;//是否出现过非零数字
//示例: 800 --->8
//示例2 8001 --->1008
//示例3108001 --->100801
while (n) {
int a = n % 10;
n /= 10;
//出现过非0数字
if (a == 0 && !flag) continue;
else if (!flag) flag = true;
cout << a;
}
return 0;
}