feat: implement recursive function przestaw with call counting

Co-authored-by: aider (openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
baiobelfer 2025-09-04 13:49:29 +02:00
commit 22915dbf6a

33
main.c Normal file
View File

@ -0,0 +1,33 @@
#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;
}