判断是否为回文数
来源:互联网 发布:csgo画面优化设置 编辑:程序博客网 时间:2024/06/05 19:43
/* * Copyright (c) 2013, 烟台大学计算机学院* All rights reserved.* 作 者:王颖* 完成日期:2013 年 11 月 06 日* 版 本 号:v1.0** 输入描述: 无* 问题描述:判断是否为回文数* 程序输出:是否是回文* 问题分析:略* 算法设计:略*/#include <iostream>using namespace std;int main(){ int isplindrome(int m); int m; cout<<"请输入一个数:"; cin>>m; if(isplindrome(m)) cout<<" "<<m<<"是回文数,欧耶爱!!!!"<<endl; else cout<<" "<<m<<"不是回文数╮(╯▽╰)╭。回文有什么好的!"<<endl; return 0;}bool isplindrome(int n){ bool plinddrome=false;//先默认不是回文数 int m,k; m=n; k=0; while(m>0) { k=k*10+m%10; m=m/10; } if(k==n) { plinddrome=true; return plinddrome; } else return 0;}