fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. typedef std::vector<std::vector<int>> PUD;
  5.  
  6. PUD MakeHoge(PUD& In){
  7. PUD Ret;
  8. for (std::size_t i = 0; i < In.size() - 1; i++){
  9. Ret.push_back(std::vector<int>());
  10. for (std::size_t j = 0; j < In[i].size();j++){
  11. Ret[i].push_back(In[i][j]);
  12. }
  13. for (std::size_t j = 0; j < In[i].size();j++){
  14. Ret[i].push_back(In[i+1][j]);
  15. }
  16. }
  17. return std::move(Ret);//why std::move dosnt work??? on vc2013ee. because move to Temp object?
  18. }
  19.  
  20. int main(){
  21. PUD PU{ { 31 }, { 41 }, { 59 }, { 2 }, };
  22. while (PU.size() != 1){
  23. PU=MakeHoge(PU);
  24. for (auto& v : PU){
  25. std::cout << '(';
  26. for (auto& i : v){
  27. std::cout << i << ' ';
  28. }
  29. std::cout << ')';
  30. }
  31. std::cout << std::endl;
  32. }
  33. int Total = 0;
  34. for (auto& i : PU) {
  35. for (auto& j : i){
  36. Total += j;
  37. }
  38. }
  39. std::cout <<"Total="<< Total << std::endl;
  40. return 0;
  41. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
(31 41 )(41 59 )(59 2 )
(31 41 41 59 )(41 59 59 2 )
(31 41 41 59 41 59 59 2 )
Total=333