fork download
  1. #include <stdio.h>
  2. //引数の絶対値を返す関数
  3. int abs(int x){
  4. if(x<0){
  5. x=-1*x;
  6. }return x;
  7. }
  8. //引数の二乗を返す関数
  9. int square(int x){
  10. return x*x;
  11. }
  12. //main関数
  13. int main(void) {
  14. int a,b;
  15. a = 1;
  16. b = -2;
  17. printf("|%d^2 - %d^2| = %d\n",a,b,abs(square(a) - square(b)));
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
|1^2 - -2^2| = 3