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 ...
随机推荐
- 1.5---字符串压缩(CC150)
import java.util.*; public class Zipper { public String zipString(String str) { // write code here i ...
- apache poi 生成excel
ExcelBuilder.Java package com.coracle.yk.xmanager.util.poi; import com.coracle.yk.xframework.util.Bl ...
- ubuntu14.04 server 安装vmware worktation 12
0) Do the basic system installation of Ubuntu 14.04 LTS (Server or Desktop) 1) wget the installer wg ...
- 《Head First Servlet JSP》学习笔记一
- 深入浅出Java回调机制
本文转载自http://hellosure.iteye.com/blog/1130176 在网上看到了一个比喻,觉得很形象,这里借用一下: 你有一个复杂的问题解决不了,打电话给你的同学,你的同学说可以 ...
- Rubix - ReactJS Powered Admin Template 后台管理框架
Rubix - ReactJS Powered Admin Template 后台管理框架,使用 ReactJS. http://rubix400.sketchpixy.com/ltr/charts ...
- 给一个正在运行的Docker容器动态添加Volume
给一个正在运行的Docker容器动态添加Volume本文转自:http://dockone.io/article/149 [编者的话]之前有人问我Docker容器启动之后还能否再挂载卷,考虑到mnt命 ...
- Java中使用Socket实现服务器端和客户端通讯
创建服务器端serverSocket import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt ...
- java读取excel
/* * this function will read from excel * and will return the items of excel */ public static String ...
- ffmpeg-20160517-git-bin-v2
ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 f ...