10 条题解

  • 0
    @ 2024-10-24 9:45:25

    #include<iostream> #include<vector> using namespace std;

    int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); vector<int> arr; int value = 0; int num = 0; int sum = 0; while (1) { cin >> value; if (value != 0) { arr.push_back(value); if (value % 2 == 0) { num++; } else { sum += value; } } else { break; } }

    cout << "偶数的个数:" << num << endl << "奇数的总值:" << sum << endl;
    return 0;
    

    }

    • 0
      @ 2024-8-12 17:02:39
      #include <iostream>
      using namespace std;
      int main() {
          int a,sum=0,sum2=0;
          while (true)
          {
              cin >> a;
              if (a == 0) {
                  break;
              }
              if (a % 2 == 0) {
                  sum++;
              }
              else {
                  sum2+=a;
              }
          }
          cout << sum << endl << sum2;
          return 0;
      }
      一行+顺便判断,没了
      
      • 0
        @ 2024-4-17 21:01:47

        #include<bits/stdc++.h> using namespace std; #define endl '\n' #define int long long signed main(){ vector<int>arr1; int n; int sum=0,ans=0; while(cin>>n){ if(n0){ break; } else{ arr1.push_back(n); } } for(auto i:arr1){ if(i%20){ ans++; } else{ sum+=i; } } cout<<ans<<endl<<sum;

        return 0;
        

        }

        • 0
          @ 2024-4-11 17:34:58
          #include<bits/stdc++.h>
          
          using namespace std;
          
          int main()
          {
          	int n,num;
          	long long sum;
          	num = 0;
          	sum = 0;
          	while(true){
          		cin >> n;
          		if(n == 0){
          			break;
          		}
          		else if(n % 2 == 0){
          			num++;
          		}
          		else{
          			sum += n;
          		}
          	}
          	cout << num << endl << sum;
          	return 0;
          }
          
          • 0
            @ 2024-4-9 16:19:31

            n=map(int,input().split()) ans=0 total=0 for i in n: if i0: break if i%20: ans+=1 else: total+=i print(ans) print(total)

            • 0
              @ 2024-4-7 23:46:20
              #include <bits/stdc++.h>
              using namespace std;
              
              int  main()
              {
              	ios::sync_with_stdio(0);
              	cin.tie(0);
              	cout.tie(0);
              	int n;
              	int o_count = 0;
              	int j_count = 0;
              	while(cin >> n){
              		if(n == 0) break;
              		else{
              			if(n % 2 == 0) o_count++;
              			else j_count += n;
              		}
              	}
              	cout << o_count << endl << j_count;
              	
              	
              	return 0;
               } 
              
              • 0
                @ 2024-4-7 14:49:07
                #include <stdio.h>
                using namespace std;
                int main(){
                
                int count=0;
                int sum=0;
                int x;
                while(cin>>x){
                if(x==0)break;
                if(x%2==0){count++;
                }else{sum+=x;
                }
                
                }
                cout<<count<<endl<<sum;
                }
                

                `

                • 0
                  @ 2024-4-7 8:44:41
                  #include<bits/stdc++.h>
                  using namespace std;
                  typedef long long LL;
                  
                  int main()
                  {
                  	ios::sync_with_stdio(0);
                  	cin.tie(0);
                  	cout.tie(0);
                  	int sum=0,num=0;
                  	int n;
                  	while(cin>>n,n!=0)
                  	{
                  		if(n&1)sum+=n;
                  		else num++;
                  	}
                  	cout<<num<<endl<<sum<<endl;
                  	return 0;
                  }
                  
                  • 0
                    @ 2024-4-5 13:39:39
                    //模拟题
                    #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;
                    }
                    ``
                    
                    • 0
                      @ 2024-4-5 9:21:52
                      #include <bits/stdc++.h>
                      using namespace std;
                      
                      int main()
                      {
                          int n, sum1 = 0,sum2 = 0;//sum1为偶数统计,sum2为奇数统计
                          while(cin >> n && n)//n不等于0便一直读入
                          {
                              if(n % 2 ==0) sum1++;
                              else sum2 += n;
                          }
                          cout << sum1 <<endl;
                          cout << sum2;
                          return 0;
                      }
                      
                      • 1

                      信息

                      ID
                      8
                      时间
                      1000ms
                      内存
                      256MiB
                      难度
                      5
                      标签
                      递交数
                      1477
                      已通过
                      574
                      上传者