fork download
  1. #include <stdio.h>
  2.  
  3. int abs(int n);
  4.  
  5. int main(void) {
  6. int n,result;
  7. scanf("%d",&n);
  8. result=abs(n);
  9. printf("%dの絶対値は%d\n",n,result);
  10. }
  11.  
  12. int abs(int n){
  13. if( n < 0) n=-n;
  14. return n;
  15. }
Success #stdin #stdout 0.01s 5328KB
stdin
-100
stdout
-100の絶対値は100