F数圈圈

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;
}


转载于:https://www.cnblogs.com/fayne/p/7224841.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值