2 条题解

  • 3
    @ 2025-8-9 11:49:15

    抄题解不关我事(

    不用栈的解法:

    #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;
    }
    
    • 1
      @ 2026-8-3 15:34:07
      #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;
      }
      
      • 1

      信息

      ID
      5541
      时间
      1000ms
      内存
      125MiB
      难度
      1
      标签
      递交数
      56
      已通过
      40
      上传者