#include <stdio.h>
#include <string.h>
int N;
int size; void main()
{
scanf("%d", &N);
getchar(); //读取残留的回车符
for(int i = ; i < N; i++)
{
int index = ;
char strIn[] = {'\0'};
char strOut[] = {'\0'};
int count['Z'] = {'\0'}; gets(strIn); //从键盘读取字符串
size = (int)strlen(strIn);
for(int j = ; j < size; j++)
{
if(strIn[j] >= 'A' && strIn[j] <= 'Z')
{
count[strIn[j]]++; //统计字母个数
}
else
return;
}
for(int i = 'A'; i < 'Z'; i++) //输出每个字母的个数
{
if(count[i] != ) //如果输入的字符串包含此字符
{
if(count[i] == )
{
strOut[index++] = i;
}
else
{
int len = ;
char str[] = {'/0'};
//strOut[index++] = count[i] + '0'; //统计相同字符个数
len = sprintf(str, "%d", count[i]);
strcat(&strOut[index], str);
index += len;
strOut[index++] = i;
}
}
}
printf("%s\n", strOut);
}
}
#include <stdio.h>
#include <string.h>
int N;
int size; void main()
{
scanf("%d", &N);
getchar(); //读取残留的回车符
for(int i = ; i < N; i++)
{
char strIn[] = {'\0'}; gets(strIn); //从键盘读取字符串
size = (int)strlen(strIn);
for(int j = ; j < size;)
{
int k = ;
if(strIn[j] >= 'A' && strIn[j] <= 'Z')
{
char temp = '\0';
temp = strIn[j];
j++;
k = ;
while(strIn[j] == temp) //判断接下来是否有相同的字母
{
j++;
k++; //统计相同的字母个数
}
//输出个数和字母
if(k > )
printf("%d", k);
printf("%c",temp);
}
}
printf("\n");
}
}


 

HDU1020字符串操作的更多相关文章

  1. python学习笔记(字符串操作、字典操作、三级菜单实例)

    字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...

  2. shell编程常用的截取字符串操作

    1.          常用的字符串操作 1.1.           替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...

  3. php字符串操作集锦

    web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...

  4. java 字符串操作和日期操作

    一.字符串操作 创建字符串 String s2 = new String("Hello World"); String s1 = "Hello World"; ...

  5. [No000078]Python3 字符串操作

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...

  6. Python 字符串操作及string模块使用

    python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...

  7. C语言字符串操作总结大全

    1)字符串操作 strcpy(p, p1)  复制字符串  函数原型strncpy(p, p1, n)   复制指定长度字符串  函数原型strcat(p, p1)   附加字符串  函数原型strn ...

  8. c# 字符串操作

    一.字符串操作 //字符串转数组 string mystring="this is a string" char[] mychars=mystring.ToCharArray(); ...

  9. C语言字符串操作总结大全(超详细)

    本篇文章是对C语言字符串操作进行了详细的总结分析,需要的朋友参考下 1)字符串操作  strcpy(p, p1) 复制字符串  strncpy(p, p1, n) 复制指定长度字符串  strcat( ...

随机推荐

  1. nginx在linux下安装

    安装前先确认是否已经安装编译包和一些依赖包如果没有安装: yum install pcre* yum install openssl* yum install zlib yum install zli ...

  2. easyUI的基础布局easyui-accordion

    ---恢复内容开始--- <html> <head> <meta charset="UTF-8"> <title>树状图</t ...

  3. Maven与Ant比较

    Maven与Ant比较 0 « 上一篇:Jenkins学习三:介绍一些Jenkins的常用功能» 下一篇:Jenkins学习四:Jenkins 邮件配置 posted @ 2015-03-25 16: ...

  4. Linux进程学习

    进程与进程管理: 清屏:system("clear"); //#include <signal.h> 进程环境与进程属性: 什么是进程:简单的说,进程就是程序的一次执行 ...

  5. Warning: strftime(): It is not safe to rely on the system's timezone settings.

    当运行程序时,会出现如下警告: Warning: strftime(): It is not safe to rely on the system's timezone settings. You a ...

  6. [LeetCode] Rectangle Area 矩形面积

    Find the total area covered by two rectilinear rectangles in a2D plane. Each rectangle is defined by ...

  7. [LeetCode] Maximal Square 最大正方形

    Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and ret ...

  8. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  9. MVC跨域CORS扩展

    一般的基于浏览器跨域的主要解决方法有这么几种:1.JSONP       2.IFrame方式    3.通过flash实现  4.CORS跨域资源共享  ,这里我们主要关注的是在MVC里面的CORS ...

  10. C 语言学习 第12次作业总结

    作业总结 本次课堂的内容为字符串相关的几个函数还有结构体. 字符串相关函数 在此之前的课程中,输入主要都是使用scanf这个函数.而在这节课上,冯老师讲解了字符串获取函数gets.在不需要控制符的情况 ...