HDOJ1020 Encoding
Problem Description 
Given a string containing only ‘A’ - ‘Z’, we could encode it using the following method:
Each sub-string containing k same characters should be encoded to “kX” where “X” is the only character in this sub-string.
If the length of the sub-string is 1, ‘1’ should be ignored.
Input 
The first line contains an integer N (1 <= N <= 100) which indicates the number of test cases. The next N lines contain N strings. Each string consists of only ‘A’ - ‘Z’ and the length is less than 10000.
Output 
For each test case, output the encoded string in a line.
Sample Input 
2 
ABC 
ABBCCC
Sample Output 
ABC 
A2B3C
简单的字符串题目 
需要注意的只有 
如果输入:AABBBAAA 
输出的是:2A3B3A 
而不是:5A3B
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int s,i,j,n,p,m;
    char a[100000],temp;
    scanf("%d",&s);
    while(s--)
    {
        scanf("%s",a);
        n=strlen(a);
        temp=a[0];
        m=1;
        for(i=1;i<=n;i++)
        {
            p=1;
            if(a[i]==temp)
            {
                m++;
            }
            if(a[i]!=temp)
            {
                p=0;
                temp=a[i];
            }
            if(p==0)
            {
                if(m==1)
                    printf("%c",a[i-1]);
                else
                    printf("%d%c",m,a[i-1]);
                m=1;
            }
        }
        printf("\n");
    }
            return 0;
}
HDOJ1020 Encoding的更多相关文章
- encoding(hdoj1020)
		
Problem Description Given a string containing only 'A' - 'Z', we could encode it using the following ...
 - javac -encoding utf8 in linux
		
由于另外负责编码的同事用的是utf-8,我用的默认的编码格式gbk,在提交代码时,为了迁就他,我打算把格式用工具转成utf-8. 转化成果后,然后在make一下,发现javac -encoding u ...
 - 创建Odoo8数据库时的“new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)“问题
		
Odoo8创建数据库时,显示如下错误信息: DataError: new encoding (UTF8) is incompatible with the encoding of the templa ...
 - Node.js Base64 Encoding和Decoding
		
如何在Node.js中encode一个字符串呢?是否也像在PHP中使用base64_encode()一样简单? 在Node.js中有许多encoding字符串的方法,而不用像在JavaScript中那 ...
 - java Properties异常:Malformed \uxxxx encoding.
		
昨天项目中遇到一个 java.lang.IllegalArgumentException: Malformed \uxxxx encoding.这样的一个异常,debug了一下发现是读取propert ...
 - svn: Can't convert string from 'UTF-8' to native encoding 的解决办法(转)
		
http://www.cnblogs.com/xuxm2007/archive/2010/10/26/1861223.html svn 版本库中有文件是以中文字符命名的,在 Linux 下 check ...
 - C# 字符编码类Encoding
		
在网络通信中,很多情况下都是将字符信息转成字节序列进行传输.将字符序列转为字节序列的过程称为编码.当这些字节传送到接收方,接收方需要逆向将字节序列转为字符序列.这个过程就是解码. 常见编码有ASCII ...
 - 字符集和字符编码(Charset & Encoding)
		
字符集和字符编码(Charset & Encoding)[转] 1.基础知识 计算机中储存的信息都是用二进制数表示的:而我们在屏幕上看到的英文.汉字等字符是二进制数转换之后的结果.通俗的说,按 ...
 - 使用英文版eclipse保存代码,出现some characters cannot be mapped using "Cp1251" character encoding.
		
some characters cannot be mapped using "Cp1251" character encoding. 解决办法:方案一: eclipse-> ...
 
随机推荐
- (转)C#中的 break 与continue 的使用和注意
			
今天学习循环中断的 break 和continue 1.首先是 break ,大家请看代码: 1 2 3 4 5 6 7 8 9 10 11 12 int a = 0; wh ...
 - C#设置与获取目录权限(.net控制ACL)
			
找到两种方式可以修改文件夹的权限 第一种: 想用c#来设置和读取ntfs分区上的目录权限,找了很多资料,未果.终于发现了一段vb.net的代码,做了修改,以C#展示给大家. using System; ...
 - [XML] Resource帮助类
			
点击下载 Resources.rar /// <summary> /// 类说明:Resources /// 编 码 人:苏飞 /// 联系方式:361983679 /// 更新网站:[u ...
 - Android 输入法键盘和activity页面遮挡问题解决
			
本文主要介绍Android中如何解决输入法键盘和activity页面遮挡的问题. 总结: 不希望遮挡设置activity属性android:windowSoftInputMode="adju ...
 - 【转自CSDN】深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換
			
深入 Microsoft.VisualBasic.Strings.StrConv 簡繁轉換 昨天又遇到一個簡繁轉換的需求, 雖然這個問題以前已經處理過了, 但是以前是用自己建立的 b52gb 和 gb ...
 - MySQL使用指南(上)
			
作者:大金刚 有很多朋友虽然安装好了mysql但却不知如何使用它.在这篇文章中我们就从连接MYSQL.修改密码.增加用户等方面来学习一些MYSQL的常用命令. 一.连接MYSQL. 格式: mys ...
 - vecor预分配内存溢出2
			
vector预分配内存溢出导致原始的 迭代器 失效 consider what happens when you add the one additional object that causes t ...
 - 去掉Visual Studio 编辑器里中文注释的红色波浪线    转载
			
我们通常用visual studio进行开发的时候,我们通常会用到一款比较流行比较方便的插件,那就是Visual Assist X,它可以增强Microsoft开发环境下的编辑能力,支持C/C++,C ...
 - [转] 博闻强识:了解CSS中的@ AT规则 ---张鑫旭
			
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=4900 大家可能在CS ...
 - 我的第一篇博客:requestAnimationFrame学习笔记
			
通常,我们在浏览器中写动画会用到哪些技术呢? flash 可以实现一些非常复杂的动画,但随着HTML5的成熟,个人感觉flash终究会成为明日黄花. css3 当前大部分现代浏览器已经对css3支持的 ...