inf2023M/main.c

34 lines
765 B
C
Raw Permalink Normal View History

#include <stdio.h>
static int call_count;
long long przestaw_wrapper(long long n) {
call_count++;
long long r = n % 100;
long long a = r / 10;
long long b = r % 10;
n = n / 100;
if (n > 0) {
return a + 10 * b + 100 * przestaw_wrapper(n);
} else {
if (a > 0) {
return a + 10 * b;
} else {
return b;
}
}
}
int main() {
long long test_values[] = {316498, 43657688, 154005710, 998877665544321LL};
int num_tests = 4;
for (int i = 0; i < num_tests; i++) {
call_count = 0;
long long result = przestaw_wrapper(test_values[i]);
printf("n: %lld, result: %lld, call count: %d\n", test_values[i], result, call_count);
}
return 0;
}