'commit'
This commit is contained in:
30
TangDou/LuoGuBook/P1307_3.cpp
Normal file
30
TangDou/LuoGuBook/P1307_3.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int n;
|
||||
const int N = 15;
|
||||
int b[N], idx;
|
||||
|
||||
int main() {
|
||||
cin >> n;
|
||||
//特判
|
||||
if (n == 0) {
|
||||
printf("0");
|
||||
exit(0);
|
||||
}
|
||||
//如果是负数,输出负号
|
||||
if (n < 0) n = -n, printf("-");
|
||||
//数位分离
|
||||
while (n) {
|
||||
int a = n % 10;
|
||||
n /= 10;
|
||||
b[idx++] = a;
|
||||
}
|
||||
//下标
|
||||
int i = 0;
|
||||
//去掉前导0
|
||||
while (!b[i]) i++;
|
||||
//输出
|
||||
for (; i < idx; i++)cout << b[i];
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user