将字符串转化为整数
将字符串转化为整数
http://www.nowcoder.com/questionTerminal/44d8c152c38f43a1b10e168018dcc13f
C++ 4行
class Solution { public: int atoi(const char *str) { if(str[0] == '\0') return 0; stringstream ss(str); int res;ss >> res; return res; } };
将字符串转化为整数
http://www.nowcoder.com/questionTerminal/44d8c152c38f43a1b10e168018dcc13f
C++ 4行
class Solution { public: int atoi(const char *str) { if(str[0] == '\0') return 0; stringstream ss(str); int res;ss >> res; return res; } };
相关推荐