Ad
Fundamentals

This one is even more succinct.

Code
Diff
  • #include <stdio.h>
    
    int helloCplusplus(){
      puts("Hello Cplusplus\n");
      return 0;
    }
    • #include <stdio.h>
    • int helloCplusplus(){
    • printf("Hello Cplusplus
    • ");
    • puts("Hello Cplusplus
    • ");
    • return 0;
    • }

Declared variables, but only to reinterpret its type. I had to do this, because of floating point wide known precision problems.
Imho better to violate the letter of the rules a little, and obey the spirit, than pretending that something is equal, when it isn't.

Code
Diff
  • #include <algorithm>
    #include <math.h>
    
    template< class T >
    void Swap( T& a, T& b ) 
    {
      /*
     	a = (reinterpret_cast<long long >(a) + reinterpret_cast<long long >(b));
    	b = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
    	a = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
      */
      
      long long plla = *((long long*) &a); 
      long long pllb = *((long long*) &b);
      plla = plla + pllb ;
      pllb = plla - pllb ;
      plla = plla - pllb ;
      
      a =*((T*) &plla);
      b =*((T*) &pllb);
      
    }
    • #include <algorithm>
    • #include <math.h>
    • template< class T >
    • void Swap( T& a, T& b )
    • {
    • a = a + b;
    • b = a - b;
    • a = a - b;
    • /*
    • a = (reinterpret_cast<long long >(a) + reinterpret_cast<long long >(b));
    • b = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
    • a = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
    • */
    • long long plla = *((long long*) &a);
    • long long pllb = *((long long*) &b);
    • plla = plla + pllb ;
    • pllb = plla - pllb ;
    • plla = plla - pllb ;
    • a =*((T*) &plla);
    • b =*((T*) &pllb);
    • }