抄题解不关我事(
不用栈的解法:
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { vector<int> a; int x; while (cin >> x) { if (x == 0) break; a.push_back(x); } reverse(a.begin(), a.end()); for (auto &i : a) cout << i << " "; return 0; }
#include<iostream> using namespace std; int main(){ int x; long long number[100]; int o=0; while(true){ cin >> x; if(x == 0) break; else{ number[o] = x; o++; } } for(int i=o-1;i >= 0;i--){ cout << number[i] << ' '; } return 0; }
使用您的 蒙青创OJ 通用账户