Skip to content

Instantly share code, notes, and snippets.

@pureexe
Created August 5, 2013 09:22
Show Gist options
  • Select an option

  • Save pureexe/6154578 to your computer and use it in GitHub Desktop.

Select an option

Save pureexe/6154578 to your computer and use it in GitHub Desktop.
#include<iostream>
using namespace std;
int blink(int n)
{
static bool b;
static int a=0;
if((n%2==0&&b==false))
{
a=0;
}
else if(n%2==1&&b==true)
{
a=0;
}
else
{
a++;
}
if(b%2==1)
b=false;
else
b=true;
return a;
}
int main()
{
int n,p=0,big=0;
while(1)
{
cin >> n;
if(n<=0)
{
cout << big/2;
return 0;
}
p=blink(n);
if(big<p)
{
big=p;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment