对策字符串google输出goog
来源:互联网 发布:淘宝广场舞健身球 编辑:程序博客网 时间:2024/05/22 06:19
题目:输入一个字符串,输出该字符串中对称的子字符串的最大长度。
比如输入字符串“google”,由于该字符串里最长的对称子字符串是“goog“
代码利用栈和队列实现:
// Stack1.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include<cstdio>#include<deque>#include<stack>using namespace std;int main(){//char *str="goyyogle";char *str="google";stack<char> cstack;//存储字符deque<char> cdeque;//存储对称字符串char tmpch;printf("检测字符串为%s\n",str);while(*str!='\0'){printf("%c",*str);if(cstack.empty()){cstack.push(*str);str++;continue;}tmpch=cstack.top();cstack.pop();if(tmpch==*str)//中间不存在单字符{cdeque.push_front(*str);cdeque.push_back(*str);str++;continue;}//if(!cstack.empty()&&cstack.top()==*str)//中间存在单字符//{//cdeque.push_front(tmpch);//cdeque.push_front(*str);//cdeque.push_back(*str);//cstack.pop(); //str++;//continue;//}cstack.push(tmpch);cstack.push(*str);str++;}printf("\n最大对称串...\n");while(0!=cdeque.size()){printf("%c",cdeque.front());cdeque.pop_front();}putchar('\n');system("pause");return EXIT_SUCCESS;}
- 对策字符串google输出goog
- 输入一个字符串,输出该字符串中对称的子字符串的最大长度。比如输入字符串“google”,由于该字符串里最长的对称子字符串是“goog”,因此输出4。
- goog
- oj-7-A-输出“goog luck”
- Google Gson 格式化字符串输出
- Google官方建议:如何让网站在Goog…
- 对策字符串的最大长度
- 对策字符串的最大长度。
- 求对策字符串的最大程度
- Goog drive complex
- goog js lib
- 网页被纳入Google补充结果的成因与对策
- 中国教育网用户无法访问所有google服务现状分析和对策
- 字符串输出
- 输出字符串
- 字符串输出
- 字符串输出
- 输出字符串
- Linux下netlink通信的实例代码
- 数据结构试验-快速排序-堆排序
- 双重for循环Test
- POJ1658浅析------Eva's Problem
- 黑马程序员——day07
- 对策字符串google输出goog
- spring-ibatis-Struts-Hibernate 架构图 .
- RTP的实现
- Jython_Jython Development Tools (JyDT) for Eclipse
- modem调制解调器和路由器有什么区别?
- 实现独立组件
- 德国找工作三招
- 标准C++的类型转换符
- top 20系统性能瓶颈