Acdream 1111:LSS(水题,字符串处理)
LSS
Problem Description
Time flies, four years passed, colleage is over. When I am about to leave, a xuemei ask me an ACM problem, but I can't solve it, I am 功力尽失. Please help me so that I won't lose face in front of xuemei!
Give you a string , you should find the longest substring which is of the same character.
Input
First line there is a T , represents the test cases.
next T lines will be T strings.
the length of every string is less than 100
all the characters of the strings will be lowercase letters
Output
for each test case output a number
Sample Input
1
a
Sample Output
1
Source
Manager
#include <iostream> using namespace std; int main()
{
int T,i;
cin>>T;
while(T--){
char a[];
cin>>a;
//统计最长连续相同字符子串长度
int num=,sum=;
for(i=;a[i];i++){
if(a[i]==a[i-])
num++;
else
num=;
if(num>sum)
sum=num;
}
cout<<sum<<endl;
}
return ;
}
Freecode : www.cnblogs.com/yym2013
Acdream 1111:LSS(水题,字符串处理)的更多相关文章
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ytu 1064: 输入三个字符串,按由小到大的顺序输出(水题,字符串处理)
1064: 输入三个字符串,按由小到大的顺序输出 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 471 Solved: 188[Submit][Sta ...
- poj 1007:DNA Sorting(水题,字符串逆序数排序)
DNA Sorting Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 80832 Accepted: 32533 Des ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- ytu 1052: 写一函数,将两个字符串连接(水题,指针练习)
1052: 写一函数,将两个字符串连接 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 343 Solved: 210[Submit][Status][ ...
- 1222: FJ的字符串 [水题]
1222: FJ的字符串 [水题] 时间限制: 1 Sec 内存限制: 128 MB 提交: 92 解决: 20 统计 题目描述 FJ在沙盘上写了这样一些字符串: A1 = “A” A2 = ...
- 1001 字符串“水”题(二进制,map,哈希)
1001: 字符串“水”题 时间限制: 1 Sec 内存限制: 128 MB提交: 210 解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...
- 暑假训练Round1——G: Hkhv的水题之二(字符串的最小表示)
Problem 1057: Hkhv的水题之二 Time Limits: 1000 MS Memory Limits: 65536 KB 64-bit interger IO format: ...
- sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)
n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...
随机推荐
- hihoCoder 1303 数论六·模线性方程组
Description 求解模线性方程组, \(m_i\) 不互质. Sol 扩展欧几里得+中国剩余定理. 首先两两合并跟上篇博文一样. 每次通解就是每次增加两个数的最小公倍数,这对取模任意一个数都是 ...
- BZOJ 1044: [HAOI2008]木棍分割
Description 求 \(n\) 根木棍长度为 \(L\) ,分成 \(m\) 份,使最长长度最短,并求出方案数. Sol 二分+DP. 二分很简单啊,然后就是方案数的求法. 状态就是 \(f[ ...
- Droid4x安装busybox
下载Busybox ...
- Docker configure http proxy
from: http://stackoverflow.com/questions/23111631/cannot-download-docker-images-behind-a-proxy That' ...
- c#.net对excel的操作——创建一个excel报表两个sheet就是2个表分别添加内容
添加引用:Microsoft.Office.Interop.Excel //创建excel对象,就是实例化一个excel对象 Application excel=new Appl ...
- 【leetcode】Next Permutation
Next Permutation Implement next permutation, which rearranges numbers into the lexicographically nex ...
- Debian安装python-rrdtool
... sudo apt-get install rrdtool sudo apt-get install librrd-dev sudo apt-get install python-dev pip ...
- selenium源码分析-webdriver(二)
最近比较空闲就仔细看了一下Selenium的源码,因为主要是使用WebDriver所以重点关注了一下WebDriver的工作原理.在前一篇blog里已经解释过了WebDriver与之前Selenium ...
- c++ 文件utf-8格式
#include <stdio.h> int i = 0; while (i < 20) { i++; WriteLog("d:\\log.txt", ...
- net use与shutdown配合使用,本机重启远程服务器
net use与shutdown配合使用,本机重启远程服务器 今天服务器出现问题了,能ping通,但就是远程登录服务器后,服务器无法响应. 在本机测试发现ftp服务可以使用,于是就想通过ftp ...