第十一周项目判断参数是否是回文数

来源:互联网 发布:数据化运营速成手册 编辑:程序博客网 时间:2024/05/21 10:04
/*  *Copyright (c)2014,烟台大学计算机学院  *All gight reserved.  *文件名称:temp.cpp  *作者:曾晓  *完成时间:2014年11月10日  *版本号:v1.0 */ #include <iostream>  using namespace std;  bool ispalindrome(int n);  int main( ) {    int m;    cin>>m;    if (ispalindrome(m))        cout<<"是回文数,噢耶!"<<endl;    else        cout<<"不是回文数。回文有什么好!"<<endl;    return 0;   }    bool ispalindrome (int n)     {         int r,s=0,x;         x=n;         while (x>0)         {             r=x%10;             s=s*10+r;             x=x/10;         }         return (s==n);     }

运行结果:

 

运行结果:

 

 

 

 

  心得:编写这个程序的时候,在返回函数值的地方出了点错误,导致输入任何一个数输出的都不是回文数。好不容易对了。><

0 0