std::cin >> q;
                  
                  
                  
                  
                  
                      for (int i = 0; i < q; ++i) {
                  
                  
                          std::string operation_code;
                  
                  
                          getline(std::cin, operation_code);
                  
                  
                  
                  
                  
                          std::string result_command;
                  
                  
                          std::string result_number;
                  
                  
                  
                  
                  
                  
                  
                  
                          for (int i = 0; i <= operation_code.size(); ++i) {
                  
                  
                              if (i == operation_code.size()) {
                  
                  
                                  result_number = result_command;
                  
                  
                              } else if (operation_code[i] == ' ') {
                  
                  
                                  result_command.clear();
                  
                  
                              } else {
                  
                  
                                  result_command.push_back(operation_code[i]);
                  
                  
                              }
                  
                  
                          }
                  
                  
                  
                  
                  
                          std::cout << "result_command: " << result_command << std::endl;
                  
                  
                          std::cout << "result_number: " << result_number << std::endl;
                  
                  
                  
                  
                  
                      }
                  
                  
                  }
                  
                  
                  
                  
                  
                  2
                  
                  
                  result_command: 
                  
                  
                  result_number: 
                  
                  
                  WORRY 2
                  
                  
                  result_command: 2
                  
                  
                  result_number: 2
                  
                  
                  
                  
                  
                  почему первая итерация пролетает и он не отсанавливается на getline(std::cin, operation_code); ???
                  
                  
                
Ты не считал \n после первого cin, он там остался, в итоге getline вернул пустую строку
Обсуждают сегодня