编写一个程序,判断一个四位整数是否为回文数,就是顺度与逆读得出的数字一样,用c++语言怎么讲啊

来源:百度知道 编辑:UC知道 时间:2024/05/30 08:21:04

#include <stdio.h>
main()
{
int i;
printf("请输入要查询的整数");
scanf("%d",i);
if(i\000==i%1000%100%10&&i%1000\100==i%1000%100\10)
printf("yes");
else
printf("No");
}
这样编最简单,因为你只说明是四位整数。

既然你已经说了是4位的,那么就用超级简单、固定、死板、弱智的方法实现一个:
#include <iostream>

using namespace std;

int main()
{
int hw;

cin >> hw;

if (hw/1000 == hw%10 && hw%1000/100 == hw/10%10)
cout << "is_hw" << endl;
else
cout << "isnot_hw" << endl;
}

1、这个程序的效率高
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool substring_is_huiwen(string s,int start,int end) //判断的具体实现函数
{
if (start >= end)