fork download
  1.  
  2. #include <iostream>
  3.  
  4. struct Point {
  5. int x;
  6. int y;
  7. };
  8.  
  9. struct Rectangle {
  10. Point topLeft;
  11. int width;
  12. int height;
  13. };
  14.  
  15. int main() {
  16. Point p1 = {10, 20};
  17.  
  18. Point p2 = {5};
  19.  
  20. Rectangle rect = {{0, 0}, 100, 50};
  21.  
  22. std::cout << "Point p1: x=" << p1.x << ", y=" << p1.y << std::endl;
  23. std::cout << "Point p2: x=" << p2.x << ", y=" << p2.y << std::endl;
  24. std::cout << "Rectangle: topLeft=(" << rect.topLeft.x << "," << rect.topLeft.y
  25. << "), width=" << rect.width << ", height=" << rect.height << std::endl;
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
Point p1: x=10, y=20
Point p2: x=5, y=0
Rectangle: topLeft=(0,0), width=100, height=50