Example #1
0
int main(void) {
	Solution *s = new Solution();
	string s1 = "-3924x8fc";
	string s2 = "+413";
	string s3 = "++c";
	string s4 = "++1";
	string s5 = "2147483648";
	string s6 = "+2147483647";
	string s7 = "-2147483648";
	string s8 = "-2147483647";
	string s9 = "-2147483649";
	
	cout << "Solution 1: " << s->myAtoi(s1) << endl;
	cout << "Solution 1: " << s->myAtoi(s2) << endl;
	cout << "Solution 1: " << s->myAtoi(s3) << endl;
	cout << "Solution 1: " << s->myAtoi(s4) << endl;
	cout << "Solution 1: " << s->myAtoi(s5) << endl;
	cout << "Solution 1: " << s->myAtoi(s6) << endl;
	cout << "Solution 1: " << s->myAtoi(s7) << endl;
	cout << "Solution 1: " << s->myAtoi(s8) << endl;
	cout << "Solution 1: " << s->myAtoi(s9) << endl;
	
	delete s;
	return 0;
}
Example #2
0
File: 8.cpp Project: cedarz/ltcode
int main() {
    Solution s;
    cout << s.myAtoi("-123hell") << endl;
    cout << s.myAtoi("-+123hell") << endl;
    cout << s.myAtoi("18446744073709551617") << endl;
    
    return 0;
}
int main(int argc, char *argv[])
{
    string nums="9223372036854775809";
    Solution so;
    cout << so.myAtoi(nums) << endl;
    return 0;
}
Example #4
0
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    Solution s;
    std::cout << s.myAtoi("-340.1") << std::endl;
    return 0;
}
Example #5
0
int main()
{
	string a = "-2147483649";
	Solution sol;
	cout << sol.myAtoi(a) << endl;
	return 0;
}
Example #6
0
int main(int argc, char ** argv) {

    vector<string> cases = {
        "000",
        "+000",
        "-000",
        "+1111",
        "-1234",
        "12345",
        "91234784",
        "asdf123",
        "       123",
        "    1234asdf",
        "2147483647",
        "-2147483648",
        "2147483648",
        "-2147483649",
        "214748364721474836472147483647",
    };

    Solution s;
    for(auto str : cases) {
        cout << "----------" << endl;
        cout << str << endl;
        cout << s.myAtoi(str) << endl;
        cout << atoi(str.c_str()) << endl;
    }
    return 0;
};
Example #7
0
int main()
{
	int result;
	Solution solute;
	result = solute.myAtoi(string("-3924x8fc"));
	return 0;
}
Example #8
0
int main(int argc ,char **argv)
{
	Solution s;
	string s1 = (" -1 23 89");
	cout<<s.myAtoi(s1)<<endl;
	return 0;
}
int main()
{
	string s = "-9223372036854775809";
	Solution sol;
	cout << sol.myAtoi(s) << endl;
    return 0;
}
Example #10
0
int main(void) {
    Solution s = Solution();
    cout << s.myAtoi("9223372036854775809") << endl;

    system("pause");
    return 0;
}
Example #11
0
int main()
{
	Solution s;
	string str = "2147483648";
	int a = s.myAtoi(str);
	cout<< a <<endl;
	return 0;
}
int main()
{
  Solution s;
  int ret;

  string s1;
  ret = s.myAtoi(s1);
  expect_true(ret,0);

  string s2 = "-123";
  ret = s.myAtoi(s2);
  expect_true(ret,-123);

  string s3 = "-123s90";
  ret = s.myAtoi(s3);
  expect_true(ret,-123);

  string s4 = "-000001";
  ret = s.myAtoi(s4);
  expect_true(ret,-1);

  string s5 = "     +004500";
  ret = s.myAtoi(s5);
  expect_true(ret,4500);

  string s6 = "2147483648";
  ret = s.myAtoi(s6);
  expect_true(ret,2147483647);
  
  string s7 = "-2147483647";
  ret = s.myAtoi(s7);
  expect_true(ret,-2147483647);
  return 0;
}
Example #13
0
int main()
{
	Solution sol;
	string s = "-2147483648";
	cout << sol.myAtoi(s) << endl;


	return 0;
}
Example #14
0
void main()
{
	Solution sol;
	cout << sol.myAtoi("-2147483648");


	system("pause");
	return;
}
Example #15
0
int main(int argc, char const *argv[])
{
	string s="-00021474asda";
	Solution so;
	cout<<so.myAtoi(s)<<endl;
	// int min=(numeric_limits<int>::min)()/10;
	// int minremain=(numeric_limits<int>::min)()%10;
	// cout<<min<<"\t"<<minremain<<endl;
	return 0;
}
Example #16
0
int main(int argc, char const *argv[])
{
	Solution test;
	string str;
	cout << "input the string to change" << endl;
	cin >> str;
	int result = test.myAtoi(str);
	cout << result << endl;
	return 0;
}
Example #17
0
int main(){
	Solution s;
	cout << (s.myAtoi("") == 0) << endl;
	cout << (s.myAtoi("abc") == 0) << endl;
	cout << (s.myAtoi("1") == 1) << endl;
	cout << (s.myAtoi(" 1") == 1) << endl;
	cout << (s.myAtoi(" -1") == -1) << endl;
	cout << (s.myAtoi(" +1") == 1) << endl; 
	cout << (s.myAtoi("    1234a") == 1234) << endl;
	cout << (s.myAtoi("2147483648") == 2147483647) << endl;
	cout << (s.myAtoi("2147483647") == 2147483647) << endl;
	cout << (s.myAtoi("-2147483648") == -2147483648) << endl;
	cout << (s.myAtoi("-2147483649") == -2147483648) << endl;
	cout << (s.myAtoi("9223372036854775809") == INT_MAX) << endl;
	cout << s.myAtoi("9223372036854775809") << endl;
	cout << (9223372036854775809 > LONG_MAX) << endl;
	cout << INT_MAX / 10 << endl;
	return 0;
}
Example #18
0
int main(int argc, char *argv[])
{
    // testString(); 
    Solution sln;

    string s(argv[1]);
    cout << "sln.myAtoi(" << s <<  ") is: " << sln.myAtoi(s) << endl;

    // int num = -2147483647;
    // cout << "num is: " << num << endl;
    // cout << (num <= INT_MIN) << endl;

    // cout << (2147483648 >= INT_MAX) << endl;

    return 0;
}
Example #19
0
void test(){
    Solution s = Solution();
    // "42" -> 42
    assert(42 == s.myAtoi("42"));
    // "    -42" -> -42
    assert(-42 == s.myAtoi("      -42"));
    // "4193 with words" -> 4193
    assert(s.myAtoi("4193 with words") == 4193);
    // "words and 987" -> 0
    assert(s.myAtoi("words and 987") == 0);
    // "-91283472332" -> -2147483648
    assert(s.myAtoi("-91283472332") == -2147483648);
    // "20000000000000000000" -> 2147483647
    assert(s.myAtoi("20000000000000000000") == 2147483647);
}
int main()
{
	Solution so;
	cout<<so.myAtoi("9223372036854775809");
	
}
Example #21
0
int _tmain(int argc, _TCHAR* argv[])
{
	Solution so;
	std::cout << so.myAtoi("  -0012a42");
	return 0;
}
Example #22
0
int main(){
    Solution sol;
    string s = "   +0 123";
    cout<<sol.myAtoi(s);
    return 0;
}
int LEET_STRING_TO_INTEGER_ATOI()
{
    Solution solution;
    cout << solution.myAtoi("123") << endl;
    cout << solution.myAtoi("+123") << endl;
    cout << solution.myAtoi("-123") << endl;
    cout << solution.myAtoi(" 123") << endl;
    cout << solution.myAtoi(" +123") << endl;
    cout << solution.myAtoi(" -123") << endl;
    cout << solution.myAtoi(" -0") << endl;
    cout << solution.myAtoi(" +0") << endl;
    cout << solution.myAtoi("") << endl;
    cout << solution.myAtoi("x") << endl;
    cout << solution.myAtoi("2147483646") << endl;
    cout << solution.myAtoi("2147483647") << endl;
    cout << solution.myAtoi("2147483648") << endl;
    cout << solution.myAtoi("-2147483647") << endl;
    cout << solution.myAtoi("-2147483648") << endl;
    cout << solution.myAtoi("-2147483649") << endl;
    return 0;
}
Example #24
0
int main() {
    Solution s;
    cout<<s.myAtoi("1234")<<endl;
    return 0;
}
Example #25
0
int main()
{
    Solution sol = Solution();
    string str = "    +1468ab345";
    cout << "Convert \"" << str << "\" To integer, the result is: " << sol.myAtoi(str) << endl;
}
Example #26
0
int main(){
	Solution s;
	cout<<s.myAtoi("   -0012a   ");
	return 0;
}
Example #27
0
int main(){
    Solution so;
    cout << so.myAtoi("+-1213434") <<endl;
}
int main(int argc, char** argv) {
	Solution solution;
	cout << solution.myAtoi("9223372036854775809") << endl;
	return 0;
}
int main () {
    Solution sol;
    string aa("  -0012a42");
    cout << sol.myAtoi(aa) << endl;
}