Problem Description
传说中有一题小学生题,难倒了一万个大学生:
7111=0 5555=0
8809=6 8193=3
2171=0 8096=5
……
2889=?
这题居然是数圈圈!!数圈圈有木有啊数圈圈。
我也是醉了。。
好吧。今天我们就来数圈圈吧!
题目很简单 给你一个数 告诉我有多少个圈圈。来吧!
(注意:4是没有圈圈的!)
Input
输入数据有多个,每个占一行,每行一个整数,保证每个数不会大于5位,没有小数。
Output
对于每个输入数据,输出一行,有多少个圈圈。
Sample Input
7111
8809
2171
2889
Sample Output
0
6
0
5
考虑前导0(例如0001)、只有0和负数的情况。也可以用字符串做~
#include#include int main() { int num,t,tl,aws; while (~scanf("%d", &num)) { aws = 0; if (num < 0) num = -num; if (num == 0) aws = 1; while (num) { tl = num % 10; num = num / 10; if (tl == 0 || tl == 6 || tl == 9) aws++; if (tl == 8) aws += 2; } printf("%dn", aws); } return 0; }
发表回复