Description
幼儿园的小朋友对数字其实不是很感兴趣,他们更感兴趣的是形状,现在给你一个数字,小朋友都会数出其中一共有多少圆圈圈
Input
一个数字n长度不超过19位
Output
输出其中的圈圈数总数
Sample Input
14589
20869
12357
Sample Output
Hint
3
5
0
#include <stdio.h>
#include <string.h>
int sc(char m)
{
int s = 0;
if ( m == '6'||m == '9' || m == '0')
s = 1;
if ( m == '8')
s = 2;
return s;
}
int main()
{
char a[20];
int k, s,i;
while ( 1 == scanf("%s",a))
{
s = 0;
k = strlen(a);
for (i=0; i<k; ++i)
s += sc(a[i]);
printf("%d\n",s);
}
return 0;
}
//标准代码
#include <stdio.h>
#include <stdlib.h>
int q[] = {
1, 0, 0, 0, 0, 0, 1, 0, 2, 1,
};
int main(){
long long n;
int s;
freopen("A.in", "r", stdin);
freopen("A.out", "w", stdout);
while (~scanf("%I64d", &n)){
s = 0;
while (n)
s += q[n % 10], n /= 10;
printf("%d\n", s);
}
return 0;
}