『sprintf』题解 | #好数#
好数
http://www.nowcoder.com/practice/59ff66115ebb465f9cbb0d7c14c0b5b9
class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
* 判断x是不是好数
* @param x int整型 待判断的数
* @return bool布尔型
*/
bool judge(int x) {
// write code here
char Help[10];
sprintf(Help, "%d", x);
int Len=strlen( Help );
return Help[0]==Help[Len-1];
}
}; 