📄 llmain.cpp
字号:
// llmain.cpp
#include <iostream.h>
#include "..\include\book.h"
typedef int ELEM;
#include "..\include\link.h"
#include "..\include\llist.h"
// This is poor style to include this code. The only reason I do it
// is because otherwise lprint.c would need to include the proper
// list header, which would require a separate lprint.c version for
// array-based and linked lists.
#include "lprint.c"
main()
{
list L1;
list L2(15);
list L3;
L2.append(10);
print(L2);
L2.append(20);
L2.append(15);
print(L2);
L1.setFirst();
L1.insert(39);
L1.next();
L1.insert(12);
L1.append(5);
L1.append(4);
L1.append(3);
L1.append(2);
L1.append(1);
print(L1);
L2.setFirst();
L2.find(20);
if (L2.isInList())
cout << "L2 curr: " << L2.currValue() << "\n";
else
cout << "Odd - what happened to 20?\n";
cout << "L1: "; print(L1);
cout << "Size: " << L1.length() << "\n";
cout << "L2: "; print(L2);
cout << "L3: "; print(L3);
L1.setFirst();
L1.find(20);
if (L1.isInList())
cout << "Odd - shouldn't find 20 in L1!\n";
else
cout << "20 not in L1.\n";
L1.setFirst();
L1.find(5);
if (L1.isInList())
cout << L1.currValue() << "\n";
L2.setFirst();
L2.find(20);
if(L2.isInList())
cout << L2.currValue() << "\n";
else
cout << "Didn't find it the first time\n";
L2.next();
L2.find(20);
if (L2.isInList())
cout << "Found it again!\n";
else
cout << "Only once in list.\n";
L1.setFirst();
cout << L1.currValue() << "\n";
L1.setValue(42);
print(L1);
L2.setFirst();
cout << "Removing: " << L2.remove() << "\n";
cout << "Removing: " << L2.remove() << "\n";
print(L2);
cout << "Size: " << L2.length() << "\n";
L2.clear(); print(L2);
cout << "Size: " << L2.length() << "\n";
L2.append(5); print(L2);
cout << "Start a new round.\n";
L2.clear();
print(L2);
L2.setFirst();
L2.insert(1);
print(L2);
L2.insert(2);
print(L2);
L2.setPos(2);
L2.insert(3);
print(L2);
cout << "That is all.\n";
cout << "-----------------------\n";
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -