fork download
  1. #include <stdio.h>
  2.  
  3. // プロトタイプ宣言
  4. double power(double x, int n);
  5.  
  6. int main(void) {
  7. double a;
  8. int b;
  9.  
  10. scanf("%lf,%d", &a, &b);
  11. printf("%f ^ %d\n",a,b);
  12. printf("%f\n",power(a,b));
  13. return 0;
  14. }
  15.  
  16. // 関数xのn乗
  17. double power(double x, int n)
  18. {
  19. int i;
  20. double ans=1.0;
  21.  
  22. for(i=0; i<n; i++)
  23. ans *= x;
  24.  
  25. return ans;
  26. }
  27.  
Success #stdin #stdout 0s 5284KB
stdin
3,3
stdout
3.000000 ^ 3
27.000000