C++ 栈实现:输入数字并逆序输出
#include <iostream>
#include <stack>
using namespace std;
int main() {
stack<int> s;
int num;
for (int i = 0; i < 5; i++) {
cin >> num;
s.push(num);
}
while (!s.empty()) {
cout << s.top() << ' ';
s.pop();
}
return 0;
}
原文地址: https://www.cveoy.top/t/topic/nIAs 著作权归作者所有。请勿转载和采集!