zoukankan      html  css  js  c++  java
  • pku2136 Vertical Histogram

    统计字符串中各个字母出现的次数并且输出一个柱状统计图,注意用鼠标去划一下,每两个‘*’柱之间有空格。。

    其他的就是模拟了,水题

    View Code
     1 program pku2136(input,output);
     2 var
     3     map   :array[0..73,'A'..'Z'] of boolean;
     4     number:array['A'..'Z'] of integer;
     5     max:longint;
     6 procedure init;
     7 var
     8     s:ansistring;
     9     i,j:longint;
    10 begin
    11     fillchar(map,sizeof(map),false);
    12     fillchar(number,sizeof(number),0);
    13     for i:=1 to 4 do
    14     begin
    15         readln(s);
    16         for j:=1 to length(s) do
    17         if (s[j] in ['A'..'Z']) then    
    18             inc(number[s[j]]);
    19     end;
    20 end;{ init }
    21 procedure main();
    22 var
    23     ch:char;
    24     i:longint;
    25 begin
    26     max:=0;
    27     for ch:='A' to 'Z' do
    28     if number[ch]>max then
    29         max:=number[ch];
    30     for ch:='A' to 'Z' do
    31         for i:=max downto max-number[ch]+1 do
    32             map[i,ch]:=true;
    33     for i:=1 to max do
    34         for ch:='A' to 'Z' do
    35         begin    
    36             if (map[i,ch]) then
    37                 write('*')
    38             else
    39                 write(' ');
    40             if ch<>'Z' then
    41                 write(' ');
    42             if ch='Z' then
    43                 writeln;
    44         end;
    45     for ch:='A' to 'Z' do
    46     begin
    47         write(ch);
    48         if ch<>'Z' then
    49             write(' ')
    50         else
    51             writeln;
    52     end;
    53 end;{ main }
    54 begin
    55     init;
    56     main;
    57 end.
  • 相关阅读:
    bzoj4033
    bzoj 1197
    bzoj 1196
    bzoj 1195
    bzoj 1194
    bzoj 1193
    bzoj 1192
    jvm系列(一):java类的加载机制
    红黑树之 原理和算法详细介绍
    TreeMap详细介绍(源码解析)和使用示例
  • 原文地址:https://www.cnblogs.com/neverforget/p/2457044.html
Copyright © 2011-2022 走看看