#B. 数字游戏(number)

    Type: Default File IO: number 1000ms 256MiB

数字游戏(number)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

【题目描述】

小K同学向小P同学发送了一个长度为8的01字符串来玩数字游戏,小P同学想要知道字符串中究竟有多少个1。

注意:01字符串为每一个字符是0或者1的字符串,如101为一个长度为3的01字符串。

【输入格式】

从文件number.in中读入数据。

输入文件只有一行,一个长度为8的01字符串​s​。

【输出格式】

输出到文件number.out中。

输出文件只有一行,包含一个整数,即01字符串中字符1的个数。

【样例1输入】

00010100

【样例1输出】

2

【样例1解释】

该01字符串中有2个字符1。

【样例2输入】

11111111

【样例2输出】

8

【样例2解释】

该01字符串中有8个字符1。

【数据范围】

image

C23本部OI练习赛

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2024-6-8 14:00
End at
2024-6-8 17:00
Duration
3 hour(s)
Host
Partic.
20