内部赛 字母统计表 格式最重要
来源:互联网 发布:大数据时代的管理变革 编辑:程序博客网 时间:2024/05/17 02:22
字母统计表
Description :
有一串字符串S,全部由小写字母组成,现在要你统计每个字母表的个数,打表输出,具体格式见Output。
Input :
多组输入。
每一组输入输入S,|S| < 260;
Output :
见Sample Output,不能输出任何多余字符,输出的字符铺满整个矩形(输出的字符边界最大值作为矩形的长宽)。
Sample Input :
aabcdefghijklmnopqrstuvwxy
a
Sample 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
*
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
#include<stdio.h>
#include<string.h>
int main()
{
int l;
char s[1000];
char a[26]={'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'};
while(scanf("%s",s)!=EOF)
{
char c[260][26];
for(int i=0;i<260;i++)
for(int j=0;j<26;j++)
c[i][j]=' ';
int num[26]={0},d;
getchar();
l=strlen(s);
for(int i=0;i<l;i++)
for(int j=0;j<26;j++)
if(s[i]==a[j])
num[j]++;
int max=num[0];
for(int i=1;i<26;i++)
{ if(num[i]>max)
max=num[i];
}
d=260-max;
for(int i=0;i<26;i++)
for(int j=259;j>=260-num[i];j--)
c[j][i]='*';
for(int i=d;i<=259;i++)
for(int j=0;j<26;j++)
{
if(j<25)
printf("%c ",c[i][j]);
else printf("%c\n",c[i][j]);}
for(int i=0;i<26;i++)
{
printf("%c",a[i]);
if(i<25)
printf(" ");
}
printf("\n");
}
return 0;
}
一开始给c数组初始化时,只给第一个元素赋了值。导致后面没有填满矩形。
- 内部赛 字母统计表 格式最重要
- 分析网站内部优化最重要的因素
- 内部赛题目 学学格式控制
- 密码格式 数字+字母
- 字母 表示 时间格式 写法
- Thinkphp 单字母内部函数 ADSLCFI
- 代码统计表
- 个人信息统计表
- 柱状图统计表
- 统计表大小
- 自定义统计表
- 日期格式各字母的含义
- DLL函数内部记录格式初探
- TGA文件内部格式详解(转)
- OpenGL 纹理内部格式 Texture Internal Formats
- 统计表中的字段数目
- 户数统计表
- ORACLE 9i 统计表
- 综合课程设计第二次作业
- python idle调出上一次输入
- 【Theano】单层带先验感知器:3月18日调试日志
- 跨域访问-预请求及跨域常见问题
- Hibernate 缓存机制
- 内部赛 字母统计表 格式最重要
- STL算法replace,replace_if,replace_copy.replace_copy_if
- 16中国App年度排行榜及17年趋势预测
- mysql导入导出sql文件
- 链表
- git branch 相关介绍
- Maven学习笔记
- 汉诺塔问题
- 表达式求值