mirror of
https://github.com/krahets/hello-algo.git
synced 2026-02-03 19:03:42 +08:00
* docs: add Japanese documents (`ja/docs`) * docs: add Japanese documents (`ja/codes`) * docs: add Japanese documents * Remove pythontutor blocks in ja/ * Add an empty at the end of each markdown file. * Add the missing figures (use the English version temporarily). * Add index.md for Japanese version. * Add index.html for Japanese version. * Add missing index.assets * Fix backtracking_algorithm.md for Japanese version. * Add avatar_eltociear.jpg. Fix image links on the Japanese landing page. * Add the Japanese banner. --------- Co-authored-by: krahets <krahets@163.com>
41 lines
985 B
C++
41 lines
985 B
C++
/**
|
|
* File: stack.cpp
|
|
* Created Time: 2022-11-28
|
|
* Author: qualifier1024 (2539244001@qq.com)
|
|
*/
|
|
|
|
#include "../utils/common.hpp"
|
|
|
|
/* ドライバーコード */
|
|
int main() {
|
|
/* スタックを初期化 */
|
|
stack<int> stack;
|
|
|
|
/* 要素プッシュ */
|
|
stack.push(1);
|
|
stack.push(3);
|
|
stack.push(2);
|
|
stack.push(5);
|
|
stack.push(4);
|
|
cout << "Stack stack = ";
|
|
printStack(stack);
|
|
|
|
/* スタックトップ要素にアクセス */
|
|
int top = stack.top();
|
|
cout << "Top element of the stack top = " << top << endl;
|
|
|
|
/* 要素ポップ */
|
|
stack.pop(); // 戻り値なし
|
|
cout << "Element popped from the stack = " << top << ", after popping";
|
|
printStack(stack);
|
|
|
|
/* スタックの長さを取得 */
|
|
int size = stack.size();
|
|
cout << "Length of the stack size = " << size << endl;
|
|
|
|
/* 空かどうかを判定 */
|
|
bool empty = stack.empty();
|
|
cout << "Is the stack empty = " << empty << endl;
|
|
|
|
return 0;
|
|
} |