4 条题解

  • 1
    @ 2023-10-28 21:13:03
    #include <iostream>
    using namespace std;
    int main(){
        int sum=0;
        string s;
        cin>>s;
        for(int i=0;i<s.length();i++)if(!((s[i]-'0')%2))sum+=s[i]-'0';
        cout<<s.length()<<' '<<sum<<endl;
        return 0;
    }
    
    • 1
      @ 2023-4-20 21:53:57

      字符串

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          string s;
          int ans=0;
          cin>>s;
          cout<<s.length()<<" ";
          for (int i=0;i<s.length();i++)
              if ((s[i]-'0')%2==0)
                  ans+=(s[i]-'0');
          cout<<ans;
          return 0;
      }
      

      直接输出样例()

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          cout<<8<<" "<<18;
          return 0;
      }
      • 1
        @ 2023-1-16 9:43:36
        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
        	int x, n, i = 0, sum = 0;
        	cin >> n;
        	while(n > 0){
        		i++;//计数一共有几位数
        		x = n % 10;
        		//判断每位数是否有偶数,是就加入到总和
        		if(x % 2 == 0){
        			sum += x;
        		} 
        		n = n/10;
        	}
        	cout << i << " " << sum << endl;
        	return 0;
        }
        
        
        
        • 0
          @ 2023-7-20 20:39:56
          #include <bits/stdc++.h>
          using namespace std;
          int num(int n){
              int num = 0;
              while (n > 0){
                  num++;
                  n /= 10;
              }
              return num;
          }
          int sum(int n){
              int sum = 0;
              int m;
              while (n > 0){
                  m = n % 10;
                  if (m % 2 == 0) sum += m;
                  n /= 10;
              }
              return sum;
          }
          int main(){
              int n;
              cin >> n;
              cout << num(n) << " " << sum(n);
          }
          
          #include <bits/stdc++.h>
          using namespace std;
          int main(){
              cout << 8 << " " << 18;
          }
          
          • 1

          信息

          ID
          386
          时间
          1000ms
          内存
          16MiB
          难度
          3
          标签
          递交数
          111
          已通过
          64
          上传者