fork download
  1. #include <stdio.h>
  2. int calc(int n){
  3. if(n<0){
  4. n=-n;
  5. int a=1;
  6. for(int i=n;i>0;i--){
  7. a=a*i;
  8. }return a;
  9. }
  10. }
  11.  
  12. int main(void) {
  13. int n;
  14. n=-5;
  15. printf("%dの絶対値の階乗は%d",n,calc(n));
  16. // your code goes here
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
-5の絶対値の階乗は120