fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. using namespace std;
  4. union
  5. {
  6. int i;
  7. char c[4];
  8. } A,B;
  9. int main()
  10. {
  11. while( scanf("%d",&A.i)==1 )
  12. {
  13. B.c[0]=A.c[3];
  14. B.c[1]=A.c[2];
  15. B.c[2]=A.c[1];
  16. B.c[3]=A.c[0];
  17. printf("%d converts to %d\n",A.i,B.i);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 2688KB
stdin
123456789
-123456789
1
16777216
20034556
stdout
123456789 converts to 365779719
-123456789 converts to -349002504
1 converts to 16777216
16777216 converts to 1
20034556 converts to -55365375