fork download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4.  
  5. int fac(int n)
  6. {
  7. if (n<0)
  8. printf("Error!");
  9. else
  10. return pow(2,n);
  11. }
  12.  
  13. int main()
  14. {
  15. int x;
  16. printf("請輸入指數x的值:");
  17. scanf("%d",&x);
  18. printf("x=%d,此時2的x次方為%d\n",x,fac(x));
  19. system("pause");
  20. return 0;
  21. }
  22.  
Success #stdin #stdout #stderr 0s 3300KB
stdin
2
stdout
請輸入指數x的值:x=2,此時2的x次方為4
stderr
sh: pause: not found