@ayubsayyad/

ThirdScarceScales

C++11

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
#include <algorithm>

template<typename T>
 T reverse(T& val){
     char* begin = (char*)&val;
     char* end = begin + sizeof(T) -1;

     while(begin < end){
         std::swap(*begin++, *end--);
     }
     //std::reverse(begin, end);
     return val;
 }

 int main(){
     double d = 0;
     scanf("%lf", &d);
     auto d1 = reverse<double>(d);
    printf("%f", d1);
 }