一道很简单的C语言题。。。我的答案正确却不能AC

来源:百度知道 编辑:UC知道 时间:2024/06/09 09:03:11
#include<stdio.h>
#include<math.h>
void main()
{
int n,i,j,d;
char a[1000],b[1000];
while(scanf("%d",&n)!=EOF)
{
scanf("%s %s",a,b);
for(i=0,j=n-1;i<n,j>=0;i++,j--)
{
if(a[i]-'0'==b[j]-'0')
d=1;
else
{
d=0;
break;
}
}
if(d!=0)
{
printf("Yes.\n");
for(i=0;i<n;i++)
printf("in\n");
for(i=0;i<n;i++)
printf("out\n");
printf("FINISH\n");
}

else
{
printf("No.\n");
printf("FINISH\n");
}

}
}
以下是题目。。英文的。。希望高手不要嫌麻烦。。本人小白。请帮帮我吧
汗。摆渡吃连结?题目:http://acm.hdu.edu.cn/showproblem.php?pid=1022

这题没你想想那么简单,要用栈来做的
输入 4 1234 1342
你的程序 输出是no,应该是yes的
in
out
in
in
out
in
out
out
程序的思路就是错的。。。。。。
这是一份AC的C++代码,应该可以看懂 ,楼主可以仿照这个用C 写下

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

const int Max=100;

int Locate(char array[],char num,int low,int high)
{
for(; array[low]!=num && low<=high ;low++);
if(array[low]!=num)
return -1;
else
return low;
}

int main()
{
int loc,n,i,j,step;
char order1[Max],order2[Max],station[10];
int run[Max];
int top,po1;
bool flag;

while(cin>>n)
{
cin>>order1;
cin>>order2;

memset(station,0,sizeof(station));
top=po1=step=0;
flag=true;
for(i=0;i<n;i++)
{
loc=Locate(station,order2[i],0,top); //在车站的位置
if(loc<0)
{
loc=Locat