main.cpp
来自「斯坦福Energy211/CME211课《c++编程——地球科学科学家和工程师》」· C++ 代码 · 共 54 行
CPP
54 行
#include <iostream>#include "datastructs.h"using namespace std;int main(){ // Q is a singly-linked list Queue<double> Q; // Add numbers to the end Q.EnQueue( 3.0 ); Q.EnQueue( 4.0 ); // Iterate from front to back Queue<double>::Iterator i; for ( i = Q.Begin(); i != Q.End(); i++ ) cout << *i << endl; // Remove both numbers Q.DeQueue(); Q.DeQueue(); // Confirm that iteration over an empty list works for ( i = Q.Begin(); i != Q.End(); i++ ) cout << *i << endl; cout << endl; // D is a doubly-linked list DQueue<int> D; // Add the numbers 0 through 9, in that order for ( int j = 0; j < 10; j++ ) D.PushBack( j ); // Then, iterate through the list from back to front DQueue<int>::ReverseIterator r; for ( r = D.RBegin(); r != D.REnd(); r++ ) cout << *r << endl; cout << endl; // Remove the first and last numbers D.PopFront(); D.PopBack(); // Iterate again to confirm they're removed for ( r = D.RBegin(); r != D.REnd(); r++ ) cout << *r << endl;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?