求一C语言程序~~

来源:百度知道 编辑:UC知道 时间:2024/06/10 13:55:43
输入并判断字符串是否回文~~

急求~~!!!

#include<iostream>
#include<string>
using namespace std;

int main()
{
string str;
cout<<"输入字符串";
cin>>str;

int length=str.length();
bool b=false;
for(int i=0;i<length/2;i++)
if(str[i]==str[length-i-1])
b=true;
else {b=false;break;}
if(b) cout<<"该字符串是回文\n";
else cout<<"该字符串不是回文\n";
return 0;
}

#include "stdio.h"
#include "conio.h"
main( )
{
long ge,shi,qian,wan,x;
scanf("%ld",&x);
wan=x/10000;
qian=x%10000/1000;
shi=x%100/10;
ge=x%10;
if(ge==wan&&shi==qian)/*个位等于万位并且十位等于千位*/
printf("this number is a huiwen\n");
else
printf("this number is not a huiwen\n");
getch();
}

重新再来!