fork(1) download
  1. #include <stdio.h>
  2. int power(int x, int n){
  3. if (n==0||x==1){
  4. return 1;
  5.  
  6. }
  7. else return x*power(x,n-1);
  8. }
  9.  
  10. int main(void) {
  11. int n,x;
  12. scanf("%d",&x);
  13. scanf("%d",&n);
  14.  
  15.  
  16. int result = power(x,n);
  17. printf("%dの%d乗は%dです。\n",x,n,result);
  18. // your code goes here
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5284KB
stdin
1
1
stdout
1の1乗は1です。