正在加载图片...
{ count[s[j]-'A]++; /得到每个大写字母出现的次数存入一维数组cout中 } 求次数的最大值 int max max =count[0]; for(i=0;i<=25;i+) { if(count[i]max)max count[i]; } ∥打印直方图 int res max; for(i=0;i<max,i++) forG=0:j<=25,j+) if(count[i]>=max-i) COut<<"*": else cout<<""; } cout <<endl; for(char ch='A':ch <='Z':ch++) { cout<<ch<<"" return 0;{ count[s[j]-'A'] ++; //得到每个大写字母出现的次数存入一维数组 count 中 } } //求次数的最大值 int max ; max = count[0]; for(i = 0; i <= 25; i ++) { if(count[i] > max) max = count[i]; } // 打印直方图 int res = max; for(i = 0; i < max; i ++) { for(j = 0; j <= 25; j ++) { if(count[j]>=max-i) { cout<<"* "; } else{ cout<<" "; } } cout <<endl; } for(char ch = 'A'; ch <= 'Z'; ch++) { cout <<ch<<" "; } return 0; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有