您的位置:首页 > 其它

zoj 1622 Switch

2012-03-11 18:07 316 查看
#include "stdio.h"
#include "memory.h"

int light[10010];

int main()
{
int i, evencount1, evencount2, oddcount1, oddcount2, evencount = 0, oddcount = 0, num;
while (scanf("%d", &num) != EOF)
{
evencount1 = 0;
evencount2 = 0;
oddcount1 = 0;
oddcount2 = 0;
memset(light, 0, sizeof(light));
for (i = 0; i < num; i++)
scanf("%d", &light[i]);
for (i = 0; i < num; i++)
{
if (i % 2 == 0 && light[i] == 0)
evencount1++;
else if (i % 2 != 0 && light[i] == 1)
oddcount1++;
else if (i % 2 == 0 && light[i] == 1)
evencount2++;
else if (i % 2 != 0 && light[i] == 0)
oddcount2++;
}
evencount = evencount1 + oddcount1;
oddcount = evencount2 + oddcount2;
if (evencount > oddcount)
printf("%d\n", oddcount);
else
printf("%d\n", evencount);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: