2014年3月12日

Palindrome Number

摘要: 1 bool isPalindrome(int x) { 2 if(x=10) 9 div*=10;10 while(x)11 {12 i=x/div;13 j=x%10;14 if(i!=j)15 return false;16 x=(x%div)/10;17 div /= 100;18 }19 return true;20 ... 阅读全文

posted @ 2014-03-12 21:09 crane_practice 阅读(171) 评论(0) 推荐(0) 编辑

String to Integer (atoi) ???

摘要: 1 #define INT_MAX 2147483647 2 #define INT_MIN -2147483648 3 class Solution { 4 public: 5 int atoi(const char *str) { 6 //string如果能转换成int的话,各位都要是数字,一个例外是第一个字符可以是负号 7 int n=strlen(str); 8 int i=0; 9 int flag=0;//0表示正值,1表示负值10 int val=0;11 /*12 ... 阅读全文

posted @ 2014-03-12 09:27 crane_practice 阅读(407) 评论(0) 推荐(0) 编辑

导航