5 条题解

  • 0
    @ 2025-3-25 19:34:37

    #include<iostream> using namespace std; int main() { int n; int count = 0, sum = 0; while (cin >> n) { if (n % 2 == 0) { count++; } else { sum += n; } } cout << count << endl << sum; return 0; //再复制之后按下快捷键ctrl+z来结束输入 }

    • 0
      @ 2024-12-12 23:33:36
      #include <bits/stdc++.h>
      
      using namespace std;
      
      int i; 
      int num_even = 0;
      int num_odd = 0;
      
      int main() {
          while(cin >> i)
              if (i % 2 == 0) 
                  num_even++;
              else
                  num_odd += i; 
          cout << num_even << endl << num_odd << endl;
          return 0;
      }
      
      • 0
        @ 2024-4-7 11:43:02
        import java.util.Scanner;
        
        public class Main {
        public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int sum = 0;
        String s = sc.nextLine();
        sc.close();
        
        String[] strArray = s.split(" "); // 使用一个空白字符作为分隔符
        
        int[] intArray = new int[strArray.length];
        for (int i = 0; i < strArray.length; i++) {
        intArray[i] = Integer.parseInt(strArray[i]); // 将每个子字符串转换为整数
        }
        
        for (int i = 0; i < intArray.length; i++) {
        if (intArray[i] % 2 == 0) {
        count += 1;
        } else {
        sum += intArray[i];
        }
        }
        System.out.println(count);
        System.out.println(sum);
        
        }
        
        
        }
        
        • 0
          @ 2024-4-6 13:34:17
          //模板
          #include <bits/stdc++.h>
          using namespace std;
          #define endl '\n'
          #define INF 0x3f3f3f3f3f3f3f3f
          #define int long long
          
          signed main(){
          	ios::sync_with_stdio(0);
          	cin.tie(0);
          	cout.tie(0);
          	
          	int n , cnt = 0 , ans = 0;
          	
          	while(cin >> n)
          	{
          		if(n % 2 == 0)
          		{
          			cnt++;
          		}
          		else{
          			ans += n;
          		}
          	}
          	
          	cout << cnt << endl	<< ans ;
          	
          	return 0;
          }
          
          • 0
            @ 2024-4-5 13:41:44
            #include <iostream>
            using namespace std;
            int a,ans,n;
            int main()
            {
              ios::sync_with_stdio(0);
              cin.tie(0);
              cout.tie(0);
              while(cin>>a)
              {
                if(a==0)break;
                if(a%2==0){
                  n++;
                }
                else
                ans+=a;
              }
              cout<<n<<"\n"<<ans;
              return 0;
            }
            
            • 1

            信息

            ID
            9
            时间
            1000ms
            内存
            256MiB
            难度
            3
            标签
            递交数
            1515
            已通过
            802
            上传者