• c语言 8-10


    1、

    #include <stdio.h>
    
    int main(void)
    {
        int i, j, ch;
        int cnt[10] = {};
        
        while((ch = getchar()) != EOF)
        {
            if(ch > '0' && ch < '9')
            {
                cnt[ch - '0']++;
            }
        }
        
        puts("show the times.");
        for(i = 0; i < 10; i++)
        {
            printf("'%d' : ", i);
            for(j = 0; j < cnt[i]; j++)
            {
                putchar('*');
            }
            putchar('
    ');
        }
        
        return 0;
    }

    2、

    #include <stdio.h>
    
    int main(void)
    {
        int i, j, ch;
        int cnt[10] = {};
        
        while((ch = getchar()) != EOF)
        {
            if(ch >= '0' && ch <= '9')
            {
                cnt[ch - '0']++;
            }
        }
        
        int max = cnt[0];
        for(i = 0; i < 10; i++)
        {
            if(cnt[i] > max)
            {
                max = cnt[i];
            }
        }
        
        for(i = max; i > 0; i--)
        {
            for(j = 0; j < 10; j++)
            {
                if(cnt[j] >= i)
                {
                    printf("   *");
                }
                else
                {
                    printf("    ");
                }
            }
            putchar('
    ');
        }
        puts("==============================================");
        for(i = 0; i < 10; i++)
        {
            printf("%4d", i);
        }
        putchar('
    ');
        return 0;
    }

    #include <stdio.h>
    
    int main(void)
    {
        int i, j, ch;
        int cnt[10] = {};
        
        while((ch = getchar()) != EOF)
        {
            if(ch >= '0' && ch <= '9')
            {
                cnt[ch - '0']++;
            }
        }
        
        int max = cnt[0];
        for(i = 0; i < 10; i++)
        {
            if(cnt[i] > max)
            {
                max = cnt[i];
            }
        }
        
        for(i = max; i > 0; i--)
        {
            for(j = 0; j < 10; j++)
            {
                if(cnt[j] >= i)
                {
                    printf("  *  ");
                }
                else
                {
                    printf("     ");
                }
            }
            putchar('
    ');
        }
        puts("=================================================");
        for(i = 0; i < 10; i++)
        {
            printf(" '%d' ", i);
        }
        putchar('
    ');
        return 0;
    }

  • 相关阅读:
    Service Discovery
    Spring security框架原理
    Redis作者谈Redis应用场景
    redis持久化RDB和AOF-转载
    MongoDB树形结构表示法
    Tomcat Connector
    ActiveMQ 负载均衡与高可用(转载)
    JS选取DOM元素的方法
    IObit Driver Booster 无法更新驱动的解决办法
    python 学习备忘
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14803847.html
Copyright © 2020-2023  润新知