题解 | #牛的力量#
牛的力量
https://www.nowcoder.com/practice/432b49537d9c4d878060468930965fc8
#include <sstream> #include <limits> class Solution { public: /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param s string字符串 * @return int整型 */ int myAtoi(string s) { // write code here istringstream sin(s); long long tmp; sin >> tmp; if (tmp > maxn) return maxn; return tmp; } const unsigned int maxn = (1 << 31) - 1; };
直接调用库即可