AC

robin88  •  7个月前


include

using namespace std;
bool huiwen(int num) {

int reversed = 0, totalnum = num, yushu=0;  
while (totalnum!=0){  
    yushu=totalnum%10;  
    reversed=reversed*10+yushu;  
    totalnum/=10;  
}  
return num == reversed;  

}
int main() {

int n=0,count=0;  
cin>>n;   
for (int i=1;i<=n;i++) {  
    if (huiwen(i)){  
        count++;  
    }  
}  
cout<<count;  
return 0;  

}


评论:

请先登录,才能进行评论