fork(1) 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. int m;
  13. scanf("%f%d\n",&x,&n);
  14. m=power(x,n);
  15. printf("%f的%d次方是:%f",x,n,m);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 5356KB
stdin
3.0 2
stdout
0.000000的2次方是:0.000000