Input:
sadjhasdhqwpopeepomcxnnbladkjkfjasjas
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
注意:
在字符串中每个小写字母的个数不会超过20个.
编程语言:C/C++.
_________________________________________________
题目意思就是每个字母有多少个,上面就输出多少@。我用一个长度为26的数组(数组int count[26])来保存每个字母的个数,然后用一个26*20(因为说了每个字母个数都不超过20个)的数组(数组chars)来记录最后输出的结果,这个数组中的刚开始初始化为空字符,每次碰到一个字母就将其赋值为@,最后只要把这个数组从最高的一排向下输出就得到结果了,但是上面好多排都可能是空字符,要从第一排含有至少一个非空字符(即@)的向下输出,所以我用了一个变量(int max_count)来记录这一排的位置。程序如下:
baidu c++吧上的一道题,布布扣,bubuko.com
原文:http://blog.csdn.net/shxcodewarrior/article/details/20053503