ACM1020:Encoding
1. Each sub-string containing k same characters should be encoded to "kX" where "X" is the only character in this sub-string.
2. If the length of the sub-string is 1, '1' should be ignored.
ABBCCC
#include <stdio.h>
#include <string.h>
int main()
{
int N, length, count;
char str[10001];
scanf("%d", &N);
while (N)
{
scanf("%s", str);
length = strlen(str);
count = 1;
for (int i = 1; i <= length; i++)
{
if (str[i] == str[i - 1])
count++;
else
{
if (count == 1)
printf("%c", str[i - 1]);
else
{
printf("%d%c", count, str[i - 1]);
count = 1;
}
}
}
printf("\n");
N--;
}
return 0;
}
ACM1020:Encoding的更多相关文章
- .NETFramework:Encoding
ylbtech-.NETFramework:Encoding 1.返回顶部 1. #region 程序集 mscorlib, Version=4.0.0.0, Culture=neutral, Pub ...
- HDU 1020:Encoding
pid=1020">Encoding Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- 《利用python进行数据分析》读书笔记--第四章 numpy基础:数组和矢量计算
http://www.cnblogs.com/batteryhp/p/5000104.html 第四章 Numpy基础:数组和矢量计算 第一部分:numpy的ndarray:一种多维数组对象 实话说, ...
- Python编码问题:UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(12
今天安装了PyScripter编辑器,刚要写代码,突然就出现异常: <span style="font-size:14px;color:#ff0000;">>&g ...
- 30天C#基础巩固------集合,File(文件操作 ),Encoding处理字符集
一:泛型 关于泛型我自己也不是很好的理解,但是具体的运用还是可以的,可以这样的理解,我们定义一个数组,但是不知道将来它是保存什么类型的值,很是矛盾,这个时候泛型就出现了,它可以解决这个场景,li ...
- Python类的特点 (3) :静态方法与类方法
Python中的方法有4种: 1)模块中的全局方法,不属于任何类,用"模块名.方法名"形式调用. 2)类中定义的实例方法,也被称为绑定方法(Bound method),这种方法的第 ...
- Python类的特点 (2) :类属性与实例属性的关系
测试代码: #encoding:utf-8 class Parent(object): x=1 #x是Parent类的属性(字段) ls=[1,2] #ls是一个列表,也是Parent类的属性(字段) ...
- Python类的特点 (1):构造函数与方法
Python中,类的特点: #encoding:utf-8 class Parent(object): x=1 #x是Parent类的属性(字段) def __init__(self): print ...
- 【20140113-2】MyEclipse生成javadoc时出错:编码GBK的不可映射字符
今天生成java doc文档时,出现了如下所示的错误: 正在装入软件包 com.wisdom.test 的源文件...F:\workspace\StringUtils\src\com\wisdom\t ...
随机推荐
- January 04 2017 Week 1st Wednesday
Nothing happens unless first a dream. 一切始于梦想. I have a dream, one day I can be the expert in this fi ...
- 关于UITableView 不能回调 tableView: cellForRowAtIndexPath的问题
做项目时始终遇到一个问题,tableview不能回调cellForRowAtIndexPath方法,导致cell不能显示. 在网上没找到合理的解决方案. 自己弄了一下,按照自己的推测解决了这个问题 首 ...
- 理解活在Iphone中的那些App (一)
关于一个app的生命 干IOS开发两年多了,如果把大学中的时间也算上,编程也有六年了.这些时间中,从一个懵懵懂懂的学徒,变成一个还算熟练的码农,也多多少少有一点反思.于是,边促成了理解活在Iphone ...
- 使用zepto实现QQ消息左滑删除效果
有这样一个需求: 1. 有一个列表,将每一个列表项左滑动出现删除按钮: 2. 右滑动隐藏删除按钮: 3. 点击这个删除按钮删除该列表项. 完成以后的效果: 这是微信网页端的页面,使用的是 zepto ...
- SOJ 1017 Power of Cryptography 库函数精度
Background Current work in cryptography involves (among other things) large prime numbers and comput ...
- 【【模板】严格次小生成树[BJWC2010]】
树上的路径怎么能没有树剖 显然,次小生成树和最小生成树只在一条边上有差距,于是我们就可以枚举这一条边,将所有边加入最小生成树,之后再来从这些并不是那么小的生成树中找到那个最小的 我们往最小生成树里加入 ...
- 【[CQOI2011]动态逆序对】
这是我的第一个数据结构套数据结构 不是线段树套\(Splay\),而是非常蛇皮的块状链表套树状数组 如果这里按照\(\sqrt{n}\)的大小来分块,那么就需要\(n\sqrt{n}\)的空间,可能开 ...
- windows安装PHP IIS MYSQL
https://www.cnblogs.com/huodong/p/4310425.html
- SpringBoot 默认日志
默认使用的这个类 org.apache.commons.logging.Log import org.apache.commons.logging.Log; import org.apache.com ...
- PyDev For Eclipse
eclipse安装Pydev 1.根据自己的eclipse和你安装的python选择可以安装的版本 Update sites for various PyDev versions: Latest ve ...