```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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 ``` ```/* Tính S(x, n) = x^n Ta cần biết + Với n > 0 (ví dụ là 3) thì x^3 là x * x * x + Với n < 0 (ví dụ là -3) thì x^-3 là: 1/(x^3) = 1/x * 1/x * 1/x */ #include #include float deQuy(float x, int n) // đệ quy { if(n == 0) return 1; if(n == -1) return 1.0/x; if(n < 0) return deQuy(x, n + 1) * 1.0 / x; else if(n == 0) return 1; return deQuy(x, n - 1) * x; } float deQuyDuoi(float x, int n, float y = 1) // đệ quy đuôi { if(n == 0) return y; if(n < 0) return deQuyDuoi(x, n + 1, y * 1.0 / x); else if(n == 0) return 1; return deQuyDuoi(x, n - 1, y * x); } float khuDeQuy(float x, int n) // khử đệ quy { bool Check = true; float tich = 1; if(n == 0) return tich; else if(n < 0) { Check = false; n *= -1; // biến thành dương lại } for(int i = 1; i <= n; i++) { tich *= x; } if(Check == true) return tich; return 1.0/tich; } int main() { float x = 2; int n; printf("\nNhap n: "); scanf("%d", &n); printf("\nKhu de quy(%f, %d) = %f", x, n, khuDeQuy(x, n)); printf("\nDe quy(%f, %d) = %f", x, n, deQuy(x, n)); printf("\nDe quy duoi(%f, %d) = %f", x, n, deQuyDuoi(x, n)); getch(); return 0; } ```
 ```1 2 3 4 5 6 7 8 9 10 11 ``` ```Line 17: error: conio.h: No such file or directory Line 26: error: expected ';', ',' or ')' before '=' token In function 'khuDeQuy': Line 39: error: 'bool' undeclared (first use in this function) Line 39: error: (Each undeclared identifier is reported only once Line 39: error: for each function it appears in.) Line 39: error: expected ';' before 'Check' Line 46: error: 'Check' undeclared (first use in this function) Line 46: error: 'false' undeclared (first use in this function) Line 50: error: 'for' loop initial declaration used outside C99 mode Line 54: error: 'true' undeclared (first use in this function) ```