fork download
  1. #include <stdio.h>
  2. double power(double x,int n){
  3. double p=1;
  4. int i;
  5. for(i=1;i<=n;i++)
  6. p=p*x;
  7. return p;
  8. }
  9. int main(void) {
  10. double x;
  11. int n;
  12. double m;
  13. scanf("%lf%d\n",&x,&n);
  14. m=power(x,n);
  15. printf("%lf的%d次方是:%lf",x,n,m);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5352KB
stdin
  6.0 2
stdout
6.000000的2次方是:36.000000