5 条题解

  • 2
    @ 2025-2-12 15:49:25
    #include<iostream>
    #define yy return 0;
    using namespace std;
    int a[1000005];
    int main(){
    	int x,i=1;
    	while(cin>>x){
        if(x==0) break;
    		a[i]=x;++i;
    	}
    	cout<<a[i-1];
    	for(int j=i-2;j>=1;--j) cout<<" "<<a[j];
    	yy
    }
    • 1
      @ 2025-3-31 19:22:56
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int a[10005],n=1,r,m=1;/*m是计数器*/
          while(cin>>r)
          {
              if(r==0) break;
              a[n]=r;n++;
              m++;
          }
          for(int i=m-1;i>=1;i--) cout<<a[i]<<" ";/*以为已0结尾,所以i=m-1*/
          return 0;
      }
      
      
      • 1
        @ 2024-11-10 9:54:19

        简单题!祝大家 AKIOI。

        #include<bits/stdc++.h>
        using namespace std;
        int a[1000001],c,t=0;
        int main()
        {
        	for(int i=1;;i++){
        		cin>>c;
        		if(c==0)break;
        		else{
        			a[i]=c;
        			t++;
        		}
        	}
        	for(int i=t;i>=1;i--)cout<<a[i]<<" ";
        	return 0;
        }
        
        • 1
          @ 2024-10-24 15:48:28
          #include<iostream>
          using namespace std; 
          int x[100],c = 0;
          int main() {
              for (int i = 0; ;i++) {
                  cin >> x[i];
                  if (x[i] == 0) break; c = i;
              }
              for (int j = c;j >= 0;j--) cout << x[j] << " ";
              cout << endl;
              return 0;
          }
          
          • 0
            @ 2025-3-31 22:49:13

            import java.util.Scanner; import java.util.ArrayList; public class Main {

            public static void main(String[] args) {
                Scanner sc = new Scanner(System.in);
            
                //创建集合收集数据
                ArrayList<Integer> list = new ArrayList<>();
            
                //输入数据
                int num = -1;
                while (num != 0) {
                    num = sc.nextInt();
                    list.add(num);
                }
            
                //0不输出,所以要减2
                for (int i = list.size() - 2; i >= 0; i--) {
                    System.out.print(list.get(i) + " ");
                }
            }
            

            }

            • 1

            信息

            ID
            5485
            时间
            1000ms
            内存
            125MiB
            难度
            1
            标签
            递交数
            317
            已通过
            209
            上传者