| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:高手帮忙 啊啊 谢谢!!!In Reply To:高手帮忙 啊啊 谢谢!!! Posted by:442091289 at 2010-01-01 14:41:23 我是超级新手。。基本不会堆栈。。用数组为什么总是WA,试了好多次了,都是对的啊
#include <stdio.h>
#include <string.h>
int main()
{
char arr[200][200]={"http://www.acm.org/"},command[10],a[4][10]={"VISIT","BACK","FORWARD","QUIT"};
int i=1,n;
while(1)
{
scanf("%s",command);
if(strcmp(command,a[0])==0)
{
if(arr[i][1]!=0)
{
scanf("%s",arr[i]);
printf("%s\n",arr[i]);
i++;
}
else
{
n=i;
for(;arr[i][1]!=0;i++);
for(;i>n;i--)
arr[i][101]=arr[i-1][101];
scanf("%s",arr[n]);
printf("%s\n",arr[i]);
i++;
}
}
else if(strcmp(command,a[1])==0)
{
if(i<=1) printf("Ignored\n");
else
{
i=i-2;
printf("%s\n",arr[i]);
i=i+1;
}
}
else if(strcmp(command,a[2])==0)
{
if(arr[i][1]==0) printf("Ignored\n");
else
{
printf("%s\n",arr[i]);
i=i+1;
}
}
else if(strcmp(command,a[3])==0) break;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator