fork(1) download
  1. #include <stdio.h>
  2. //練習問題A
  3. int func(int n);
  4.  
  5. int main(void) {
  6. int n, m = -3;
  7. n = func(m);
  8. printf("%dの絶対値は%d\n", m,n);
  9. return 0;
  10. }
  11. int func(int n) {
  12. if (n < 0) {
  13. return -n; // 負の数なら符号を反転
  14. } else {
  15. return n; // それ以外はそのまま返す
  16. }
  17. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
-3の絶対値は3