标签:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 17966 | Accepted: 8681 |
THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.
THIS IS AN EXAMPLE TO TEST FOR YOUR
HISTOGRAM PROGRAM.
HELLO!
*
*
* *
* * * *
* * * *
* * * * * *
* * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * *
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
CODE:
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define REP(i, s, n) for(int i = s; i <= n; i ++) #define REP_(i, s, n) for(int i = n; i >= s; i --) #define MAX_N 80 using namespace std; char s[MAX_N]; int ch[27]; int main(){ memset(ch, 0, sizeof(ch)); while(gets(s + 1)){ int l = 0; l = strlen(s + 1); if(l == 0) break; REP(i, 1, l){ if(s[i] >= ‘A‘ && s[i] <= ‘Z‘) ch[s[i] - ‘A‘ + 1]++; } } int mx = 0; REP(i, 1, 26) mx = max(mx, ch[i]); REP_(i, 1, mx){ REP(j, 1, 26){ if(ch[j] < i) cout << " "; else cout << "* "; } cout << endl; } REP(i, 1, 26) cout << (char)(65 + i - 1) << ‘ ‘; return 0; }
标签:
原文地址:http://www.cnblogs.com/ALXPCUN/p/4527479.html