#include #include #include /* ===================================================================== Solving maths with the computers ===================================================================== Ex 1) Brute force atack Write a program in C language that can find (only) solutions like: (82+8+1)^2 = 8281 (14+364+1)^2 = 143641 (5+1+2)^3 = 512 (6+72+4)^2 = 6724 (842+72+4)^2 = 842724 (62+726+4)^2 = 627264 (1+29+6)^2 = 1296 (929+29+6)^2 = 929296 (9+11+25)^3 = 91125 (5+715+36)^2 = 571536 (8+2+81)^2 = 8281 but omit cases such as as: (9+12+25)^3 = 97336 (5+715+37)^2 = 573049 (8+21+81)^2 = 12100 The output of the program should be saved in txt file (the list should be extended by at least 10 more positive examples). */ #include #include //implementation of itoa (present in C++, but not in C) void itoa(int n, char s[]) { int i = 0, sign = n; if (sign < 0) { n = -n; // Handle negative numbers } do { s[i++] = n % 10 + '0'; // Extract digits by remainder } while ((n /= 10) > 0); if (sign < 0) { s[i++] = '-'; } s[i] = '\0'; // Reverse the string int start = 0, end = i - 1; while (start < end) { char temp = s[start]; s[start] = s[end]; s[end] = temp; start++; end--; } } int main() { FILE *fp; fp = fopen("/tmp/math_solutions.txt", "w"); int max_A = 100; int max_B = 1000; int max_C = 1000; int max_power = 3; int max_solution_count = 10; int solution_counter = 0; for (int a = 1; a <= max_A && solution_counter