题解:P5660 [CSP-J2019] 数字游戏

· · 题解

思路:

因为是八个数字,所以我们需要进行以下几步:

code:

#include <bits/stdc++.h>
using namespace std;

string s;
int ans = 0;

int main () {
    cin >> s;
    for (int i = 0; i <= 7; i++) {
        if (s[i] == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}