标签:else can out res include pac mes for ++
#include<iostream> #include<sstram> using namespace std; int myAtoi(string str) { string s=""; int result; bool flag=true; for(int i=0; i<str.length(); i++) { if(! ((str[i] >= ‘0‘ && str[i] <=‘9‘) || str[i] ==‘-‘|| str[i] ==‘ ‘ || str[i] == ‘+‘) ){ break; } if(str[i] == ‘ ‘ && flag){ continue; }else{ flag= false; s+=str[i]; } } int Int; // stringstream ss; // ss << s; // ss >> Int; char st[1000000]; for(int j=0; j<s.length(); j++){ st[j]=s[j]; } sscanf(st,"%d", &Int); if(Int >= INT_MAX){ result = INT_MAX; }else if(Int <= INT_MIN){ result = INT_MIN; } else{ result = Int; } return result; } int main(){ cout<<myAtoi(" +156548"); return 0; }
标签:else can out res include pac mes for ++
原文地址:https://www.cnblogs.com/zhishoumuguinian/p/9949359.html