pku1028完全c语言

#include<stdio.h>
#include<string.h>
int main(void)
{
 char s1[102][80],s2[102][80],str[80];
 int m=0,n=1;
 strcpy(s2[0],"http://www.acm.org/");
 while(scanf("%s",str)&&(strcmp(str,"QUIT")!=0)){
  if(strcmp(str,"BACK")==0){
   n--;
   if(n<=0){
    n=1;
    printf("Ignored\n");
   }
   else{
    strcpy(s1[m],s2[n]);
    m++;
    printf("%s\n",s2[n-1]);
   }
  }
  else if(strcmp(str,"FORWARD")==0){
   if(m==0)
    printf("Ignored\n");
   else{
       strcpy(s2[n],s1[m-1]);
       m--;
    printf("%s\n",s2[n]);
    n++;
   }
  }
  else{
   scanf("%s",str);
   m=0;
   strcpy(s2[n],str);
   printf("%s\n",s2[n]);
   n++;
  }
 }
 return 0;
}
posted @ 2010-07-16 18:25  闪闪金星  阅读(104)  评论(0编辑  收藏  举报