3 条题解

  • 1
    @ 2023-3-25 14:55:26
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    	double sum = 0;
    	int ans = 0;
    	string s;
        cin >> s;
        for (int i = 0; i < s.length(); i++)
        {
            if (s[i] -'!' == 32)
            {
                sum += 4;
    			ans++;
            }
            if (s[i] -'!' == 33)
            {
                sum += 3;
    			ans++;
            }
            if (s[i] -'!' == 34)
            {
                sum += 2;
    			ans++;
            }
            if (s[i] -'!' == 35)
            {
                sum += 1;
    			ans++;
            }
            if (s[i] -'!' == 10)
                sum += 0.3;
            if (s[i] -'!' == 12)
                sum -= 0.3;
        }
    	cout << fixed << setprecision(2) << sum / ans;
    	return 0;
    } //已AC
    
    • 0
      @ 2023-8-21 13:08:48
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
      	double sum = 0;
      	int ans = 0;
      	string s;
          cin >> s;
          for (int i = 0; i < s.length(); i++)
          {
              if (s[i] -'!' == 32)
              {
                  sum += 4;
      			ans++;
              }
              if (s[i] -'!' == 33)
              {
                  sum += 3;
      			ans++;
              }
              if (s[i] -'!' == 34)
              {
                  sum += 2;
      			ans++;
              }
              if (s[i] -'!' == 35)
              {
                  sum += 1;
      			ans++;
              }
              if (s[i] -'!' == 10)
                  sum += 0.3;
              if (s[i] -'!' == 12)
                  sum -= 0.3;
          }
      	cout << fixed << setprecision(2) << sum / ans;
      	return 0;
      } //已AC
      
      • 0
        @ 2023-4-19 22:29:44
        #include <iostream>
        #include <iomanip>
        using namespace std;
        int main()
        {
            double sum = 0, n = 0;
            string s;
            cin >> s;
            for (int i = 0; i < s.length(); i++)
            {
                if(s[i] == 'A')
                {
                    sum += 4;
                    n++;
                }
                if(s[i] == 'B')
                {
                    sum += 3;
                    n++;
                }
                if(s[i] == 'C')
                {
                    sum += 2;
                    n++;
                }
                if(s[i] == 'D')
                {
                    sum += 1;
                    n++;
                }
                if(s[i] == '+')
                {
                    sum += 0.3;
                }
                if(s[i] == '-')
                {
                    sum -= 0.3;
                }
            }
            cout << fixed << setprecision(2) << sum / n;
            return 0;
        }
        
        • 1

        信息

        ID
        1980
        时间
        1000ms
        内存
        256MiB
        难度
        6
        标签
        (无)
        递交数
        1336
        已通过
        380
        上传者