• 个人简介

    手撕栈的模板

    #include <bits/stdc++.h>
    using namespace std;
    int arr[1000];
    int top;//顶
    bool empty() {
    	return top==0;
    }
    void push(int x) {
    	arr[++top]=x;
    }
    int getTop() {
    	return arr[top];
    }
    void pop() {
    	top--;
    }
    int size() {
    	return top;
    }
    int main() {
    	push(9);
    	push(37);
    	cout<<getTop()<<endl;
    	pop();
    	cout<<getTop()<<endl;
    
    	return 0;
    }
    

    栈的模板(标准)

    #include <bits/stdc++.h>
    using namespace std;
    int main() {
      stack<int> stk1,stk2;
      stk1.push(1);//入栈
      stk1.empty();//栈空
      stk1.pop();//出栈
      stk1.size();//返回栈的元素个数
      stk1.top();//返回栈顶元素
      return 0;
    }  
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.

题目标签

初窥门径
2
顺序结构
2
略有小成
1
1