fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. union X
  5. {
  6. struct
  7. {
  8. int i1, i2, i3;
  9. bool b1, b2, b3;
  10. };
  11.  
  12. struct
  13. {
  14. int is[3];
  15. bool bs[3];
  16. };
  17. };
  18.  
  19. std::ostream& operator<<(std::ostream& os, const X& x)
  20. {
  21. os << "{ ";
  22. for (int i = 0; i < 3; ++i)
  23. os << x.is[i] << ' ' << x.bs[i] << ' ';
  24. return os << '}';
  25. }
  26.  
  27. int main() {
  28. for (int i = 0; i < 3; ++i)
  29. {
  30. X x;
  31. for (int j = 0; j < 3; ++j)
  32. {
  33. x.is[j] = rand();
  34. x.bs[j] = rand() % 2;
  35. }
  36. std::cout << x << '\n';
  37. }
  38. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
{ 1804289383 0 1681692777 1 1957747793 1 }
{ 719885386 0 596516649 1 1025202362 1 }
{ 783368690 1 2044897763 0 1365180540 0 }