📄 ladtiex.cpp
字号:
const int list_SIZE = 10;
typedef int ELEM;
class list { // List class ADT
public:
list(const int =list_SIZE); // Constructor
~list(); // Destructor
void clear(); // Remove all ELEMs from list
void insert(const ELEM&); // Insert ELEM at current pos
void append(const ELEM&); // Insert ELEM at tail of list
ELEM remove(); // Remove + return current ELEM
void setFirst(); // Set curr to first position
void prev(); // Move curr to previous pos
void next(); // Move curr to next position
int length() const; // Return current length of list
void setPos(const int); // Set curr to specified pos
void setValue(const ELEM&); // Set current ELEM's value
ELEM currValue() const; // Return current ELEM's value
bool isEmpty() const; // Return TRUE if list is empty
bool isInList() const; // TRUE if curr is within list
bool find(const ELEM&); // Find value (from current pos)
};
void print(list&); // Prototype for print function.
main()
{
list L1;
list L2(15);
list L3;
L2.append(12); // L2 now ( 12 )
print(L2);
L2.append(20); // L2 now ( 12, 20 )
L2.append(15); // L2 now ( 12, 20, 15 )
print(L2);
L1.setFirst();
L1.insert(39); // L1 now ( 39 )
L1.next(); // L1 now ( 39, 12 )
L1.insert(12);
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -