using System;
class MyApplication {
static int count(bool []myArr, int num) {
int myCount = 0, res = 0;
for (int i = 0; i < num; i++) {
if (myArr[i] == false)
myCount = 0;
else {
myCount++;
res = Math.Max(res, myCount);
}
}
return res;
}
public static void Main() {
bool []myArr = {false, true, false, false, false, true, true, true};
int num = myArr.Length;
Console.Write("Consecutive 1's = "+count(myArr, num));
}
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265894.html