#C14183. Count Ones in a Binary String
Count Ones in a Binary String
Count Ones in a Binary String
Your task is to count the number of occurrences of the digit 1
in a given binary string. The string represents a binary number and may even be empty. For example, if the input is 1101010
, then the output should be 4
because there are four '1's.
This problem tests your basic string manipulation skills and understanding of standard input/output operations.
inputFormat
A single line containing a binary string (composed of characters '0' and '1'). The string may be empty to represent the number zero.
outputFormat
A single integer that represents the count of '1's in the given binary string.## sample
0000000
0