杭电acm 1022 为什么提交没通过,是高手的进来看看!!

student008 2009-06-07 11:10:09
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char o1[10],o2[10];
char s[10],stack[10];
int n;
while(cin>>n)
{
cin>>o1>>o2;
int i=0,j=0,k=-1,m=0;
while(1)
{
k++;
stack[k]=o1[i];
i++;s[m]='i';m++;
while(stack[k]==o2[j])
{
s[m]='o';
m++;k--;
j++;
}
if(i==strlen(o1))
break;
}
if(k<0)
{
cout<<"Yes."<<endl;
for(int e=0;e<m-1;e++)
{
if(s[e]=='i')
cout<<"in"<<endl;
else
cout<<"out"<<endl;
}
}
else
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}


...全文
67 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
student008 2009-07-24
  • 打赏
  • 举报
回复
呵呵,想了很久我做出来了!
#include<iostream>
#include<string>
using namespace std;
int main()
{
char in[9],out[9],stack[9];
string order[20];
int n;
while(cin>>n>>in>>out)
{
int ti=0,to=0,ts=-1,i=0;
while(1)
{
stack[++ts]=in[ti++];
order[i++]="in";
while(ts!=-1&&stack[ts]==out[to])
{
ts--;to++;
order[i++]="out";
}
if(ti>=n)
break;
}
if(ts==-1)
{
cout<<"Yes."<<endl;
for(int j=0;j<i;j++)
cout<<order[j]<<endl;
}
else
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}
「已注销」 2009-06-07
  • 打赏
  • 举报
回复
看了一下,你的程序什么时候结束啊,输入0怎么也不结束,这算不算错误啊,其他的不知道你程序要实现什么,楼主说下,再看逻辑了!
光宇广贞 2009-06-07
  • 打赏
  • 举报
回复
怎么那么多做杭电的题……做北大的题去吧……

不过你的题目是什么?报的是什么错?

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧