zoukankan      html  css  js  c++  java
  • luoguoj 1598 垂直柱状图 模拟

    P1598 垂直柱状图

    Time Limit: 20 Sec  Memory Limit: 256 MB

    题目连接

    http://www.luogu.org/problem/show?pid=1598

    Description

    写一个程序从输入文件中去读取四行大写字母(全都是大写的,每行不超过72个字符),然后用柱状图输出每个字符在输入文件中出现的次数。严格地按照输出样例来安排你的输出格式。

    Input


    四行字符,由大写字母组成,每行不超过72个字符

    Output

    由若干行组成,前几行由空格和星号组成,最后一行则是由空格和字母组成的。在任何一行末尾不要打印不需要的多余空格。不要打印任何空行。

    Sample Input

    THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.
    THIS IS AN EXAMPLE TO TEST FOR YOUR
    HISTOGRAM PROGRAM.
    HELLO!

    Sample Output

                                *
                                *
            *                   *
            *                   *     *   *
            *                   *     *   *
    *       *     *             *     *   *
    *       *     * *     * *   *     * * *
    *       *   * * *     * *   * *   * * * *
    *     * * * * * *     * * * * *   * * * *     * *
    * * * * * * * * * * * * * * * * * * * * * * * * * *
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

    HINT

    题意

    题解:

    模拟题

    代码:

    //qscqesze
    #include <cstdio>
    #include <cmath>
    #include <cstring>
    #include <ctime>
    #include <iostream>
    #include <algorithm>
    #include <set>
    #include <vector>
    #include <sstream>
    #include <queue>
    #include <typeinfo>
    #include <map>
    #include <stack>
    typedef long long ll;
    using namespace std;
    #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
    #define maxn 200001
    #define mod 10007
    #define eps 1e-9
    int Num;
    char CH[20];
    //const int inf=0x7fffffff;   //нчоч╢С
    const int inf=0x3f3f3f3f;
    /*
    
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    */
    inline ll read()
    {
        ll x=0,f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    inline void P(int x)
    {
        Num=0;if(!x){putchar('0');puts("");return;}
        while(x>0)CH[++Num]=x%10,x/=10;
        while(Num)putchar(CH[Num--]+48);
        puts("");
    }
    //**************************************************************************************
    
    
    int a[30];
    int main()
    {
        string s;
        int ma=0;
        while(cin>>s)
        {
    
            for(int j=0;j<s.size();j++)
            {
                if(s[j]>='A'&&s[j]<='Z'){
                a[s[j]-'A']++;
                ma=max(a[s[j]-'A'],ma);
                }
            }
    
        }
        for(int i=ma-1;i>=0;i--)
        {
            for(int j=0;j<26;j++)
            {
                if(a[j]<=i)
                    printf(" ");
                else
                    printf("*");
                if(j!=25)
                    printf(" ");
            }
            printf("
    ");
        }
        char k='A';
        for(int i=0;i<26;i++)
        {
            printf("%c",k+i);
            if(i!=25)
                printf(" ");        
        }
    }
  • 相关阅读:
    extjs 获取Dom对象
    转: python requests的安装与简单运用
    转: python如何安装pip和easy_installer工具
    转: windows下面安装Python和pip终极教程
    JS Json数据转换
    转:永久解决火狐浏览器出现的flash版本更新问题
    python 字符编码 转换
    opencv输出图片像素值
    Mac中安装tensorflow(转)
    在linux和Mac中访问某个文件夹中所有的文件
  • 原文地址:https://www.cnblogs.com/qscqesze/p/4515970.html
Copyright © 2011-2022 走看看