5 条题解

  • 1
    @ 2023-10-6 12:42:21

    简单

    #include <bits/stdc++.h>
    using namespace std;
    bool check(int x)
    {
        int cnt = 0;
        if (x % 2 == 1)
            return false;
        while(x){
            if(x % 10 % 2 == 1)
                return false;
            x /= 10;
            cnt++;
        }
        if(cnt % 2 == 1)
            return false;
        return true;
    }
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);cout.tie(0);
        int n, x;
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            cin >> x;
            if(check(x))
                cout << x << endl;
        }
        return 0;
    }
    
    • 1
      @ 2022-11-26 17:27:30

      此题可以当字符串类型题目来做,这样简单一点。

      a=input()
      b=input().split()#分割字符串并创建列表b存放
      p=['2','4','6','8','0']#偶数
      for i in b:
          if not len(i)%2:
              flag=1
              for j in i:
                  if j not in p:
                      flag -= 1
                      break
              #j不在p中,就不符合题意,break.
              #注意到这个数的各位是偶数满足个位是偶数,即此数为偶数
              if flag:
                  print(i)
      

      Loading:20/100……

      • 1
        @ 2022-11-3 13:34:21

        没人写 我写

        #include <iostream>
        using namespace std;
        int main()
        {
            int n,a[100];
            cin >> n;
            for(int i=0;i<n;i++)
            {
                cin >> a[i];
            }
            for(int i=0;i<n;i++)
            {
                if(a[i]/1000!=0)
                {
                    if(a[i]/1000%2==0 && a[i]%1000/100%2==0 && a[i]%100/10%2==0 && a[i]%10%2==0)
                    {
                        cout << a[i] << endl;
                    }
                }
                if(a[i]/10>0 && a[i]/10<10)
                {
                    if(a[i]/10%2==0 && a[i]%10%2==0)
                    {
                        cout << a[i] << endl;
                    }
                }
            }
        }
        
        • 0
          @ 2023-10-28 21:00:21
          #include <iostream>
          using namespace std;
          bool check(int x){
              int cnt=0;
              while(x){
                  if(x%10%2)return false;
                  x/=10,cnt++;
              }
              return !(cnt%2);
          }
          int main(){
              int n,a[101];
              cin>>n;
              for(int i=1;i<=n;i++)cin>>a[i];
              for(int i=1;i<=n;i++)if(!(a[i]%2)&&check(a[i]))cout<<a[i]<<endl;
              return 0;
          }
          
          • 0
            @ 2023-9-17 16:41:44

            这题真简单!

            思路:

            初始化

            #include<bits/stdc++.h>
            using namespace std;
            int main(){
                int a,b;
                cin>>a;
                for(int i=1;i<=a;i++){
                    cin>>b;
                }
                return 0;
            }
            

            判断位数

            bool ws(int n){
                int m=0,o=n;
                while(o>0){
                    m++;
                    o/=10;
                }
                return !(m%2);
            }
            

            判断每位是不是偶数

            bool num(int n){
                while(n>0){
                    if((n%10)%2==1)return 0;
                    n/=10;
                }
                return 1;
            }
            

            判断两个条件是否符合

            int main(){
                int a,b;
                cin>>a;
                for(int i=1;i<=a;i++){
                    cin>>b;
                    if(ws(b)&&num(b))cout<<b<<'\n';
                }
                return 0;
            }
            

            当然,重要的不是这些,而是 . . . . . .

            AC代码,没AC我是狗

            #include<bits/stdc++.h>
            using namespace std;
            bool ws(int n){
                int m=0,o=n;
                while(o>0){
                    m++;
                    o/=10;
                }
                return !(m%2);
            }
            bool num(int n){
                while(n>0){
                    if((n%10)%2==1)return 0;
                    n/=10;
                }
                return 1;
            }
            int main(){
                int a,b;
                cin>>a;
                for(int i=1;i<=a;i++){
                    cin>>b;
                    if(ws(b)&&num(b))cout<<b<<'\n';
                }
                return 0;
            }
            
            • 1

            信息

            ID
            394
            时间
            1000ms
            内存
            16MiB
            难度
            1
            标签
            递交数
            50
            已通过
            35
            上传者