1 solutions

  • 0
    @ 2024-6-13 17:27:15

    模拟(100pts)

    • 从前往后遍历字符串,判断是否是1
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        string s;
        getline(cin,s); //获取字符串
        int cnt=0;
        for(auto x:s) //枚举每个字符
        {
            if(x=='1') //判断是否符合条件
            {
                cnt++;
            }
        }
        cout<<cnt;
        return 0;
    }
    
    • 1

    Information

    ID
    1063
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    10
    Tags
    # Submissions
    4
    Accepted
    3
    Uploaded By