题目大意 在一串字符串中有多少个字符1 思路 遍历字符串的每个字符,若为1则次数++ C++复制for(int i=0;i<=s.size();i++){ if(s[i]=='1'){ ans++; } } cout<<ans<<endl;