-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2016-1.c
43 lines (39 loc) · 772 Bytes
/
2016-1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void reverse(int n)
{
int bak_n = n;
int tmp = 0;
int init_flag = 1;
int zero_cnt = 0;
while (n) {
int yushu = n % 10;
tmp = 10 * tmp + yushu;
n /= 10;
if (init_flag) {
if (yushu == 0) {
zero_cnt++;
} else {
init_flag = 0;
}
}
}
n = bak_n;
if (tmp % n == 0) {
printf("%d*%d=%d\n", n, tmp / n, tmp);
} else {
printf("%d ", n);
for (int i = 0; i < zero_cnt; i++) {
printf("0");
}
printf("%d\n", tmp);
}
}
int main() {
reverse(1089);
reverse(9801);
reverse(1234);
reverse(23200);
return 0;
}