作者在 2011-12-10 12:46:53 发布以下内容
/**c语言赋值**/
#include <stdio.h>
#include <string.h>
int main()
{
char CH3[120][10];
int i,j,x=0,k=0,t,m=1,n=0,p=0;/*循环变量i,j*/
char CH1[120][70];
for (i=0; i<120; i++)
strcpy(CH1[i],"0");/*ch1[120][70]赋初值'0'*/
char CH2[4][10]= {"VISIT","BACK","FORWARD","QUIT"};/*功能按钮*/
strcpy(CH1[0],"http://www.hnguotong.com/");/*目标按钮*/
//freopen("in.txt","r",stdin);
for (t=1;; t++) /*死循环*/
{
scanf("%s",CH3[++k]);/*ch3[120][0]为null,因为是++k,改成k++*/
for (j=0; j<4; j++)
if (strcmp(CH3[k],CH2[j])==0) break;/*如果输入的是vist,back,forward,quit,退出内循环,进入外循环*/
if (j==0)/*木有执行strcmp(ch2[k],ch2[j])==0,对ch1,进行赋值*/(1)
{
scanf("%s",CH1[++n]);
printf("%s\n",CH1[n]);/**输出内容 %s 以啥符号结尾呢,**/
p=n;
x=n;
}
else if (j==1)
{
if (strcmp(CH3[k-1],"VISIT")==0)
{printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);}
else if (strcmp(CH3[k-1],"BACK")==0)
{
if (p-1>=0)
{
printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);
}
else printf("Ignored\n");
}
else if (strcmp(CH3[k-1],"FORWARD")==0)
{
if (p-1<0||strcmp(CH1[p-1],"0")==0)
printf("Ignored\n");
else
{
printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);
}
}
else printf("Ignored\n");
}
else if (j==2)
{
if (strcmp(CH3[k-1],"VISIT")==0)
printf("Ignored\n");
else if (strcmp(CH3[k-1],"BACK")==0)
{
if (strcmp(CH1[p+1],"0")==0)
printf("Ignored\n");
else
{
printf("%s\n",CH1[++p]);
strcpy(CH1[++n],CH1[p]);
}
}
else if (strcmp(CH3[k-1],"FORWARD")==0)
{
if (strcmp(CH1[p+1],"0")==0||p+1>x)
printf("Ignored\n");
else
{
printf("%s\n",CH1[++p]);
strcpy(CH1[++n],CH1[p]);
}
}
else printf("Ignored\n");
}
else break;(4)
}
}
/**另外也没有显示出菜单按钮,外循环没有跳出来(4)不可能执行,执行(1)的情况多一些,用到的函数strcpy()和strcmp(),通过strcpy()完成上传功能,效率受影响,自我赋值,交换数组下标,其它啥也木有**/
#include <stdio.h>
#include <string.h>
int main()
{
char CH3[120][10];
int i,j,x=0,k=0,t,m=1,n=0,p=0;/*循环变量i,j*/
char CH1[120][70];
for (i=0; i<120; i++)
strcpy(CH1[i],"0");/*ch1[120][70]赋初值'0'*/
char CH2[4][10]= {"VISIT","BACK","FORWARD","QUIT"};/*功能按钮*/
strcpy(CH1[0],"http://www.hnguotong.com/");/*目标按钮*/
//freopen("in.txt","r",stdin);
for (t=1;; t++) /*死循环*/
{
scanf("%s",CH3[++k]);/*ch3[120][0]为null,因为是++k,改成k++*/
for (j=0; j<4; j++)
if (strcmp(CH3[k],CH2[j])==0) break;/*如果输入的是vist,back,forward,quit,退出内循环,进入外循环*/
if (j==0)/*木有执行strcmp(ch2[k],ch2[j])==0,对ch1,进行赋值*/(1)
{
scanf("%s",CH1[++n]);
printf("%s\n",CH1[n]);/**输出内容 %s 以啥符号结尾呢,**/
p=n;
x=n;
}
else if (j==1)
{
if (strcmp(CH3[k-1],"VISIT")==0)
{printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);}
else if (strcmp(CH3[k-1],"BACK")==0)
{
if (p-1>=0)
{
printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);
}
else printf("Ignored\n");
}
else if (strcmp(CH3[k-1],"FORWARD")==0)
{
if (p-1<0||strcmp(CH1[p-1],"0")==0)
printf("Ignored\n");
else
{
printf("%s\n",CH1[--p]);
strcpy(CH1[++n],CH1[p]);
}
}
else printf("Ignored\n");
}
else if (j==2)
{
if (strcmp(CH3[k-1],"VISIT")==0)
printf("Ignored\n");
else if (strcmp(CH3[k-1],"BACK")==0)
{
if (strcmp(CH1[p+1],"0")==0)
printf("Ignored\n");
else
{
printf("%s\n",CH1[++p]);
strcpy(CH1[++n],CH1[p]);
}
}
else if (strcmp(CH3[k-1],"FORWARD")==0)
{
if (strcmp(CH1[p+1],"0")==0||p+1>x)
printf("Ignored\n");
else
{
printf("%s\n",CH1[++p]);
strcpy(CH1[++n],CH1[p]);
}
}
else printf("Ignored\n");
}
else break;(4)
}
}
/**另外也没有显示出菜单按钮,外循环没有跳出来(4)不可能执行,执行(1)的情况多一些,用到的函数strcpy()和strcmp(),通过strcpy()完成上传功能,效率受影响,自我赋值,交换数组下标,其它啥也木有**/