共有回帖数 0 个
- 发个...模拟直方图的程序.........有不好的地方还望指出.......
-
只看楼主
收藏
回复
-
#include stdio.h
#include conio.h
#include string.h
#include ctype.h
int main()
{
char a[4][80],b[26],c[330][26],d[330][26];
int i,j,k=0,m,max=0;
for(i=0;i4;i++)
{
gets(a);
}
for(i=0;i26;i++)
b=0;
for(i=0;i4;i++)
for(j=0;jstrlen(a);j++)
{
if(isupper(a[j]))
{
m=a[j]-65;
b[m]++;
}
}
for(i=0;i26;i++)
if(bmax)
max=b;
for(i=0;i26;i++)
{
for(j=0;jb;j++)
{
c[j]='*';
}
}
for(i=0;i26;i++)
{
for(j=0;jmax;j++)
d[j]=c[max-j-1];
}
for(i=0;imax;i++)
{
for(j=0;j26;j++)
{
if(b[j]!=0)
printf("%c ",d[j]);
}
printf("n");
}
for(i=0;i26;i++)
if(b!=0)
printf("%c ",i+65);
getch();
return 0;
}
========================
输入
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
就统计字母出现的个数.....
楼主 2016-02-25 14:02 回复
Copyright © 2010~2015 直线网 版权所有,All Rights Reserved.沪ICP备10039589号
意见反馈 |
关于直线 |
版权声明 |
会员须知