洛谷-训练场-新手村-简单字符串-P1598 垂直柱状图

#include
#include

int main(){
    int ans[26] = {0}, height = -1;
    char ch, table[105][60];
    memset(table, ' ', sizeof(table));
    while(scanf("%c", &ch) != EOF)
        if(ch > 64 && ch < 91) ans[ch-65]++;
    for(int i=0; i<26; i++)
        if(ans[i] > height) 
            height = ans[i];
    for(int i=0; i<26; i++)
        for(int j=height-1; j>height-1-ans[i]; j--)
            table[j][i*2] = '*';
    for(int j=0; j0; i--)
            if(table[j][i-1] == '*'){
                table[j][i] = '\0';
                break;
            }
    for(int i=0; i

解释:画图题,没啥解释的。

你可能感兴趣的:(洛谷)