Run ID:65767
提交时间:2024-02-09 19:27:47
#include <iostream> #include <string> int main() { std::string line; while (getline(std::cin, line)) { std::string a, b; size_t pos = line.find(' '); if (pos != std::string::npos) { a = line.substr(0, pos); b = line.substr(pos + 1); } else { std::cerr << "Invalid input format" << std::endl; continue; } int aValue, bValue; try { aValue = std::stoi(a); bValue = std::stoi(b); } catch (const std::invalid_argument&) { std::cerr << "Invalid integer input" << std::endl; continue; } std::cout << aValue + bValue << std::endl; } return 0; }