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 ...
随机推荐
- HDU 1024 max sum plus
A - Max Sum Plus Plus Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- centos 6.5 下用apache部署web 应用
1. 修改/etc/httpd/conf/httpd.conf文件,添加一个virtualhost段,具体略.注意在段内配置NaveServer. 此文件全局也要配置一个NameServer(原因有待 ...
- Linux查看文件编码格式及文件编码转换
Linux查看文件编码格式及文件编码转换 如果你需要在Linux 中操作windows下的文件,那么你可能会经常遇到文件编码转换的问题.Windows中默认的文件格式是GBK(gb2312),而L ...
- phalcon 前端代码结构
phalcon 前端举例: (1) baisic.phtml + basic_ajax_get.phtml + basic_ajax_post.phtml (2) basic_get.phtml ...
- (转)高性能网站架构之缓存篇—Redis集群搭建
看过 高性能网站架构之缓存篇--Redis安装配置和高性能网站架构之缓存篇--Redis使用配置端口转发 这两篇文章的,相信你已经对redis有一定的了解,并能够安装上,进行简单的使用了,但是在咱们的 ...
- spring + myBatis 常见错误:@Autowired注解失败
今天配置spring+myBatis的时候,使用注解@Autowired把持久层dao注入service层的时候总是报错. 查了好久才发现,居然是配置文件路径写错了.basepackge的路径一定要正 ...
- iOS 真机文件系统区分大小写,而模拟器可能不区分
模拟器区不区分大小写要看mac os是不是区分大小写,而这个和你的文件系统有关,如下图 如果你使用了默认的格式,就区分不了大小写了! 看来以后还是应该使用第二种格式啊!
- c++ vector struct 使用
1. //test.h #include <string> using namespace std; struct AA { string a1; string a2; string a3 ...
- 构建web应用示例
1.1 请求方法的判断 var http = require('http'); var server = http.createServer(function(request,response){ s ...
- Valentine's Day Round 1001.Ferries Wheel(hdu 5174)解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1] ...