File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -151,31 +151,31 @@ public:
151151 int StrToInt(string str) {
152152 int res = 0, bndry = INT_MAX / 10;
153153 int i = 0, sign = 1, length = str.size();
154- if(length == 0) {
154+ if (length == 0) {
155155 return 0;
156156 }
157157 // 删除首部空格
158- while(str[ i] == ' '){
159- if(++i == length) {
158+ while (str[ i] == ' ') {
159+ if (++i == length) {
160160 return 0;
161161 }
162162 }
163- //若有负号则标识符号位
164- if(str[ i] == '-') {
163+ // 若有负号则标识符号位
164+ if (str[ i] == '-') {
165165 sign = -1;
166166 }
167- if(str[ i] == '-' || str[ i] == '+') {
167+ if (str[ i] == '-' || str[ i] == '+') {
168168 i++;
169169 }
170- for(int j = i; j < length; j++) {
171- if(str[ j] < '0' || str[ j] > '9') {
170+ for (int j = i; j < length; j++) {
171+ if (str[ j] < '0' || str[ j] > '9') {
172172 break;
173173 }
174- //res>214748364越界;res=214748364且str[ j] > '7'越界
175- if(res > bndry || res == bndry && str[ j] > '7'){
174+ // res>214748364越界;res=214748364且str[ j] > '7'越界
175+ if (res > bndry || res == bndry && str[ j] > '7') {
176176 return sign == 1 ? INT_MAX : INT_MIN;
177177 }
178- //从左向右遍历数字并更新结果
178+ // 从左向右遍历数字并更新结果
179179 res = res * 10 + (str[ j] - '0');
180180 }
181181 return sign * res;
You can’t perform that action at this time.
0 commit comments