正在加载图片...
21.7-33判断回文 描述 输入一个字符串,输出该字符串是否回文。回文是指顺读和倒读都一样的字符串。 输入 输入为一行字符串(字符串中没有空白字符,字符串长度不超过100)。 输出 如果字符串是回文,输出yes:否则,输出no。 样例输入 abcdedcba 样例输出 yes #include<bits/stdc+.h>/IC+的万能头文件 using namespace std; int main() { char a[101]; gets(a)月 int ij; int n,x; n strlen(a); x=1; for(i=0.j=n-1;i<=j;i+j-) if(afil!=alil) X=0: break: if(x =1) cout <"yes"<endl: } if(x=0)2 1.7-- 33 判断回文 描述 输入一个字符串,输出该字符串是否回文。回文是指顺读和倒读都一样的字符串。 输入 输入为一行字符串(字符串中没有空白字符,字符串长度不超过 100)。 输出 如果字符串是回文,输出 yes;否则,输出 no。 样例输入 abcdedcba 样例输出 yes #include <bits/stdc++.h> //C++的万能头文件 using namespace std; int main() { char a[101]; gets(a); int i,j; int n,x; n = strlen(a); x = 1; for(i = 0,j = n-1; i <= j ; i ++,j--) { if( a[i] != a[j]) { x = 0; break; } } if( x == 1) { cout << "yes" << endl; } if( x == 0)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有