fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct ResourceFootprint {
  5. int power;
  6. int water;
  7. };
  8.  
  9. int main()
  10. {
  11. ResourceFootprint ice_well = {-100, +50};
  12. ResourceFootprint solar_array = {+150, 0};
  13.  
  14. std::vector<ResourceFootprint> buildings;
  15. buildings.push_back(ice_well);
  16. buildings.push_back(ice_well);
  17. buildings.push_back(solar_array);
  18. buildings.push_back(solar_array);
  19.  
  20. ResourceFootprint total = {0, 0};
  21. for (const ResourceFootprint& r : buildings)
  22. {
  23. total.power += r.power;
  24. total.water += r.water;
  25. }
  26.  
  27. std::cout << "P: " << total.power << ", W: " << total.water << "\n";
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
P: 100, W: 100