输出包含‘0’字符的字符串,最大连续个数
如下输入,第一第三第四行都含‘0’,但是第一行不连续,第三四行连续,所以该输出2
Input
4 5 1101 1111 0110 1011 1111
代码如下
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#include<ctype.h>
#include<algorithm>
#include<deque>
#include<functional>
#include<iterator>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#define CPY(A, B) memcpy(A, B, sizeof(A))
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = int (1e9) + 7;
const int INF = 0x3f3f3f3f;
const LL INFF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double OO = 1e20;
const double PI = acos (-1.0);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
int main() {
int n,d;
while (cin>>n>>d) {
int ls=0,max=0;
while (d--) {
string aa; int i; cin>>aa;
for (i=0; i<aa.length(); i++) {
if (aa[i]=='0') {
ls++;
if (max<ls) {
max=ls;
}
break;
}
}
if (i==n) { ls=0; }
}
cout<<max<<endl;
}
return 0;
}