zoukankan      html  css  js  c++  java
  • 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
    ",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
    ", s);
      }
      return 0;
    }


  • 相关阅读:
    vue父子组件传值的方式
    定时任务写法
    仅仅为笔记
    consul剔除某个服务
    mybatis批量查询
    一次eureka的事故
    feign的工作原理
    JVM优化
    threadlocal应用
    秋招总结
  • 原文地址:https://www.cnblogs.com/fayne/p/7224841.html
Copyright © 2011-2022 走看看