第11周项目6(2)-回文素数

来源:互联网 发布:网络布线 编辑:程序博客网 时间:2024/05/22 05:10
/* *Copyright (c) 2014, 烟台大学计算机学院 *All rights reserved. *文件名称:week11-project6-2.cpp *作者:高赞 *完成日期:2014年 11 月 7 日 *版本号:v1.0 * *问题描述:判断参数是否为回文数 */#include <iostream>#include <cstdio>using namespace std;bool isPalindrome(int);int main(){    char ch;    do    {        int m;        cin>>m;        if(isPalindrome(m))            cout<<m<<"是回文数,噢耶!"<<endl;        else            cout<<m<<"不是回文数。回文有什么好!"<<endl;        cout<<"N键退出其他键继续..."<<endl;        cin >> ch;    }    while (ch!='n' && ch!='N');    return 0;}bool isPalindrome(int x){    bool huiwen;    int X=x,y,z=0;    while (x>0)    {        y=x%10;        z=z*10+y;        x=x/10;    }    if (X==z)        huiwen=true;    else huiwen=false;    return(huiwen);}


 

运算结果:

 

0 0
原创粉丝点击