#include <iostream>
#include <string>
#include <cstdio>
using namespace std;
const int MAXN = 256;
string pages[MAXN];
int curpos, totalpos;
int main()
{
char type;
curpos = -1, totalpos = 0;
string page;
bool flag = true;
cout << "请输入浏览器命令:V(访问新网站),F(前进),B(后退),X(退出)" << endl;
while (cin >> type){
getchar();
switch(type){
case 'V':
case 'v':
cout << "请输入新的网址:";
cin >> page;
pages[curpos+1] = page;
curpos ++;
totalpos = curpos + 1;
cout << "当前网址是:" << pages[curpos] << endl;
break;
case 'b':
case 'B':
if (curpos <= 0){
cout << "无法后退!" << endl;
}
else {
curpos--;
cout << "当前网址是:" << pages[curpos] << endl;
}
break;
case 'F':
case 'f':
if(curpos+1 >= totalpos){
cout << "无法前进!" << endl;
}
else {
curpos++;
cout << "当前网址是:" << pages[curpos] << endl;
}
break;
case 'X':
case 'x':
flag = false;
break;
}
if (!flag)break;
}
return 0;
}
追问用双链表能写出来吗
这个要求两种方法😂😂
追答不行,字数太多,发不上去了,你给我个邮箱,我发给你吧,或者
我把他放在网盘上了,连接
http://pan.baidu.com/s/1dDzZ1Wt追问\^O^/十分感谢十分感谢😊
本回答被提问者采纳