2013-10-09 97 views

回答

2

以字符串形式获取答案,然后检查它是否为“q”,退出,否则将其转换为整数。

#include <iostream> 
#include <cstdlib> 

int main() { 
    std::string got; 
    std::cin >> got; 
    if(got == "q") 
      return 0; 
    else { 
      int i = std::atoi(got.c_str()); 
      std::cout << i; 
    } 
    return 0; 
} 
相关问题