3 条题解

  • 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
        标签
        递交数
        864
        已通过
        438
        上传者