/*习题4
识别依次读入的一个以字符序列是否为形为序列1&序列2模式的字符序列。
其中序列1和序列2不含&,且序列2为序列1的逆序
a+b&b+a是 a+b&b-a不是
*/
//devc++中通过
//2006.06.18
//Zyq
#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;
typedef stack<char> chars;
int check(char a[],int n)
{
chars S;
for(int i=0;i<n/2;i++)
S.push(*(a+i));
char t;
int j=1;
int i=n/2+1;
if(*(a+i-1)!='&')
return 0;
else
{
while(!S.empty()&&j)
{
j=0;
t=S.top();
S.pop();
if(t==*(a+i))
{j=1; i++;}
}
}
if(S.empty()&&j)
return 1;
else
return 0;
}
正文
练习:识别回文字符串2006-06-19 02:29:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/bclz/15978.html
阅读(2959) | 评论(0)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论