Advertisement
Guest User

Untitled

a guest
Mar 19th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. union Repr {
  5.   float f;
  6.   char b[sizeof(float)];
  7. };
  8.  
  9. void printfloat(){
  10.     float f;
  11.     cin >> f;
  12.  
  13.     cout.setf( ios::hex, ios::basefield );
  14.     Repr rep;
  15.     rep.f = f;
  16.     cout<< short(rep.b[0])<<" "<< short(rep.b[1])<<" "<< short(rep.b[2])<<" "<< short(rep.b[3])<<endl;
  17. }
  18.  
  19. int main()
  20. {
  21.     int n;
  22.     for(cin>>n; n>0; --n)
  23.      printfloat();
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement