首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 测试动态数组堆栈的实例
【标  题】:测试动态数组堆栈的实例
【关键字】:
【来  源】:http://blog.csdn.net/Micro_lee/archive/2006/12/31/1470070.aspx

测试动态数组堆栈的实例

/*_############################################################################
  _##
  _##  测试动态数组堆栈的实例
  _##  Author: xwlee                        
  _##  Time: 2006.12.31 
  _##  Chang'an University
  _##  Development condition: win2003 Server+VC6.0
  _##
  _##  temp.cpp 文件
  _##########################################################################*/
#include<iostream>
#include <ctime>
#include <iomanip>
#include "stack.h"
using namespace std;

#define TEMP_SIZE 400

int main()
{  
    STACK_TYPE temp=10;
    int i;

    create_stack( 1 );
     push( temp );
    cout << "top()=" << top() << endl;
    pop();
    cout << "is_empty()=" << is_empty() << endl;
    cout << "is_full()=" << is_full() << endl;
    destroy_stack();

    create_stack( TEMP_SIZE );
    cout<< "=======================================================" << endl;
    srand( (unsigned)time( NULL ) ); // srand()函数产生一个以当前时间开始的随机种子.
    for(i=0; i < TEMP_SIZE; i++)
        push( 1+rand()%1000 );
       
    for(i=0; i < TEMP_SIZE; i++)
    {
        cout << setw(5) << top();
        pop();
        if( (i+1) % 10 == 0 )
            cout << endl;
    }
    cout<< "=======================================================" << endl;
   
    cout << "is_empty()=" << is_empty() << endl;
    cout << "is_full()=" << is_full() << endl;

    destroy_stack();
   
    return 0;
}
一个链式堆栈模块的接口(和数组实现完全一样):【上一篇】
动态数组实现的堆栈:【下一篇】
【相关文章】
没有相关文章
【随机文章】
  • 内码转换表(转)
  • unix/linux是如何实现文件共享的?
  • 第2章 可控游戏类 2.4 梭 哈 游 戏(2)
  • Report Part 3.2.24 for Quick Report
  • maya 快捷键
  • [Socket]尴尬的CLOSE_WAIT状态以及应对策略-ZT
  • Bjarne Stroustrup语录[C++经验]
  • VB读写I/O口,弥补Visual Basic缺少函数INP、OUTP所带来的缺憾
  • 转载 js代码
  • bash shell
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.