Skip to main content
state which does what and included gcc
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

C and C++ (gcc), 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C - max language: Try it online!

C++ - min language: Try it online!

C and C++, 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

C and C++ (gcc), 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C - max language: Try it online!

C++ - min language: Try it online!

Wrong link
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60

C and C++, 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!Try it online!

C and C++, 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

C and C++, 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

added 179 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60

C and C++, 117117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

C and C++, 117 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

C and C++, 117 107 bytes

-10 bytes thanks to @Steadybox!

#include<stdio.h>
int f(int a,int b){auto c=.5;a-b&&printf("%d %d",c?b<a?b:a:a>b?a:b,c?a-b>0?a-b:b-a:a+b);}

Explanation: In C, auto c=.5 declares an integer variable with the auto storage class (which is the default), which is then initialized to 0, whereas in C++11 it declares a double, which is initialized to 0.5. So the variable's value will be truthy in C++ and falsy in C.

C: Try it online!

C++: Try it online!

added 179 characters in body
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
Removed whitespace
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading
Source Link
betseg
  • 8.7k
  • 3
  • 28
  • 60
Loading