int main(int argc, char *argv[])
{
    CQueue<int> q;
    q.appendTail(1);
    q.appendTail(2);

    cout << q.deleteHead() << endl;
    cout << q.deleteHead() << endl;
    q.appendTail(4);
    cout << q.deleteHead() << endl;
    // q.deleteHead();

    CStack<int> s;
    s.push(1);
    s.push(2);
    s.push(3);
    cout << s.top() << endl;
    s.pop();
    cout << s.top() << endl;
    s.pop();
    s.pop();
    // s.pop();

    return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	CQueue<char> queue;

	queue.appendTail('a');
	queue.appendTail('b');
	queue.appendTail('c');

	char head = queue.deleteHead();
	Test(head, 'a');

	head = queue.deleteHead();
	Test(head, 'b');

	queue.appendTail('d');
	head = queue.deleteHead();
	Test(head, 'c');

	queue.appendTail('e');
	head = queue.deleteHead();
	Test(head, 'd');
	
	head = queue.deleteHead();
	Test(head, 'e');

	return 0;
}
int main() {
    try{
        CQueue<int> cq;
        for(int i = 0; i < 10; i++) 
            cq.appendTail(i);
        for(int i = 0; i < 10; i++) 
            cout << cq.deleteHead() << ' ';
        cout << endl;
        cq.deleteHead();
    } catch(exception &e) {
        cerr << e.what() << endl;
    }


    try{
        CStack<int> cs;
        for(int i = 0; i < 10; i++) 
            cs.push(i);
        for(int i = 0; i < 10; i++) 
            cout << cs.pop() << ' ';
        cout << endl;
        cs.pop();
    } catch(exception &e) {
        cerr << e.what() << endl;
    }
    return 0;
}
示例#4
0
文件: main.cpp 项目: Howard725/offer
int main() {
    cout << "Hello, World!" << endl;

    CQueue<string> cQueue;

    cQueue.appendTail( "test1 ");
    cQueue.appendTail( "test2 ");
    cQueue.appendTail( "test3 ");

    for ( int i = 0; i < 2; ++i )
    {
        cout << cQueue.deleteHead() << endl;
    }

    cQueue.appendTail( "test4 ");
    cQueue.appendTail( "test5 ");
    cQueue.appendTail( "test6 ");

    for ( int i = 0; i < 4; ++i )
    {
        cout << cQueue.deleteHead() << endl;
    }

    cout << cQueue.deleteHead() << endl;


    system("PAUSE");
    return 0;
}
int main(){
	CQueue<char> queue;

	queue.appendTail('a');
	queue.appendTail('b');
	queue.appendTail('c');

	cout<<queue.deleteHead()<<queue.deleteHead()<<queue.deleteHead()<<endl;
	return 0;
}
示例#6
0
int main() {
    CQueue<int> aQueue;
    aQueue.appendTail(1);
    aQueue.appendTail(2);
    aQueue.appendTail(3);
    cout << aQueue.deleteHead() << endl;

    aQueue.appendTail(4);
    cout << aQueue.deleteHead() << endl;
    cout << aQueue.deleteHead() << endl;
    cout << aQueue.deleteHead() << endl;

    try {
        aQueue.deleteHead();
    } catch (exception e) {
        cout << e.what() << endl;
    }
    return 0;
}
int main() {
	CQueue<int> cq;
	int a = 1;
	int b = 2;
	int c = 3;
	int d = 4;
	cq.appendTail(a);
	cq.appendTail(b);
	cq.appendTail(c);
	cq.deleteHead();
	cq.appendTail(d);
	cq.deleteHead();
	cq.deleteHead();
	cq.deleteHead();
	cq.deleteHead();
	cq.deleteHead();

	system("pause");
	return 0;
}
示例#8
0
void algo_stack() {
	CQueue<int> queue;
	for (int i = 0; i < 10; i++) {
		queue.appendTail(i);
	}
	std::cout << "Pop:\n";
	for (int i = 0; i < 5; i++) {
		int j = queue.deleteHead();
		std::cout << j << " ";
	}
	std::cout << "\n";
	for (int i = 10; i < 15; i++) {
		queue.appendTail(i);
	}	
}