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 ...
随机推荐
- java字节码文件指令集
网上找的没有指令码这列 自己把它加上 更方便查阅 指令从0x00-0xc9 没有0xba 常量入栈指令 指令码 操作码(助记符) 操作数 描述(栈指操作数栈) 0x01 aconst_null nu ...
- centos 安装php扩展的两种方法
版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 查看PHP版本: php -v 1 1 查看指定PHP版本: /usr/local/php/bin/php -v 1 1 ...
- Qt Mysql驱动编译过程
1.首先当然是要有VS2008+Qt4.7的开发环境. 2.安装MySQL,最好是4以后的版本,安装MySQL时要勾住“C Include Files 和 Lib Files”选项,这样才能装上MyS ...
- Mysql进阶-day2
Mysql cmake方式安装 1.卸载原有mysql下载MySQL安装包 [root@localhost ~]# yum remove mysql* -y [root@localhost ~]# m ...
- Activator 通过SSH解锁屏幕等手势操作
来源:https://qunwang6.github.io/blog/Activator/ Activator 发表于 2015-10-24 | 分类于 iOS Activator Activ ...
- There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661) - skipping
Could not fetch URL https://pypi.python.org/simple/xlrd/: There was a problem confirming the ssl cer ...
- BZOJ 1295 最长距离 BFS+枚举
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=1295 题目大意: windy有一块矩形土地,被分为 N*M 块 1*1 的小格子. 有 ...
- UVA-1152-4 Values whose Sum is 0---中途相遇法
题目链接: https://cn.vjudge.net/problem/UVA-1152 题目大意: 给出4个数组,每个数组有n个数,问有多少种方案在每个数组中选一个数,使得四个数相加为0. n &l ...
- 数据类型.md
数据类型 整型 数据类型 含义(有符号) tinyint(m) 1个字节 范围(-128~127) smallint(m) 2个字节 范围(-32768~32767) mediumint(m) 3个字 ...
- UVa 1640 - The Counting Problem(数论)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...