fork download
  1. #include <stdio.h>
  2.  
  3. // x^z + y^z を計算する関数
  4. int func(int x, int y, int z) {
  5. int result_x = 1, result_y = 1;
  6. for (int i = 0; i < z; i++) result_x *= x;
  7. for (int i = 0; i < z; i++) result_y *= y;
  8. return result_x + result_y;
  9. }
  10.  
  11. int main() {
  12. int x, y, z;
  13.  
  14. printf("x, y, z を入力してください:");
  15. scanf("%d %d %d", &x, &y, &z);
  16.  
  17. int result = func(x, y, z);
  18. printf("%d^%d + %d^%d = %d\n", x, z, y, z, result);
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5316KB
stdin
2 3 4
stdout
x, y, z を入力してください:2^4 + 3^4 = 97