zoukankan      html  css  js  c++  java
  • Practice4_stack_int

    stack的第一个练习,push(int)、pop()、top()、empty()函数。

    // Practice4_stack.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <stack>
    #include <iostream>
    #include <algorithm>
    #include <stdlib.h>
    #include <time.h>
    
    using namespace std;//一定不要忘记这句
    
    void initStack(stack<int> &ss, unsigned int size)
    {
        int num = 0;
        srand(time(0));
        for(unsigned int i = 0; i < size; i++)
        {
            num = rand()%100;
            ss.push(num);
        }
    }
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        stack<int> ss;    
        initStack(ss, 5);
    
        while(!ss.empty())
        {
            cout << ss.top() << endl;
            ss.pop();
        }
        return 0;
    }
  • 相关阅读:
    6.8
    6.7
    6.2
    6.1儿童节
    5.24
    5.22
    5.18
    5.17
    Visual Studio开始一个HelloWorld的enclave程序
    以太坊MPT树的HP(Hex-Prefix)编码
  • 原文地址:https://www.cnblogs.com/liuzc/p/6491412.html
Copyright © 2011-2022 走看看