第十一周项目六 回文素数 (2)

来源:互联网 发布:python 接口 上传图片 编辑:程序博客网 时间:2024/06/01 17:47
#include <iostream>using namespace std;bool isPalindrome(int x);int main(){    int m,g;    cin>>m;    if(isPalindrome(m))        cout<<m<<"是回文数,奥耶!"<<endl;    else        cout<<m<<"不是回文数,回文有什么好!"<<endl;    return 0;}bool isPalindrome(int x){    int r,g=0,h=x;    while (x>0)    {        r=x%10;        g=g*10+r;        x=x/10;    }    return (g==h);}

0 0
原创粉丝点击