mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-23 15:48:42 +00:00
27 lines
322 B
C
27 lines
322 B
C
int get_digits(int x) {
|
|
int res = 0;
|
|
|
|
while (x) {
|
|
x /= 10;
|
|
res++;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
int get_pow(int x, int n) {
|
|
int res = 1;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
res *= x;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
int fun(int w) {
|
|
int n = get_digits(w);
|
|
|
|
return w % get_pow(10, n - 1);
|
|
}
|