2 solutions

  • 0
    @ 2026-10-21 21:12:31
    #include<iostream>
    using namespace std;
    int main()
    {
        int x;
        cin >> x;
        for (int y = 0; y < x; y++)
        {
            int a;
            cin >> a;
            if (a % 2 == 0)
            {
                cout << a << " ";
            }
            
        } 
    }
    
    • 0
      @ 2026-10-9 16:40:51

      关键点:循环中进行if判断,若为偶数就输出

      #include<bits/stdc++.h>
      using namespace std;
      typedef long long ll;
      int main(){
          ll a,b;
          cin>>a;
          while (a--){
          cin>>b;
          if(b%2==0)cout<<b<<" ";
          }
          return 0;
      }
      
      • 1

      Information

      ID
      293
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      112
      Accepted
      30
      Uploaded By