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); } }
相关文章推荐
- (水水水)zoj 1622 switch
- zoj 1622 Switch 开关灯 简单枚举
- zoj 1622 Switch 开关灯 简单枚举
- ZOJ Problem Set–1622 Switch
- ZOJ 1622 Switch
- zoj 1622 switch
- zoj1622----------------------------Switch
- zoj 1622 Switch
- ZOJ 1622 Switch
- ZOJ-1622
- 1622 Switch
- 1622_Switch
- zoj1622
- zoj 1622
- ZOJ 1622
- zoj 2405 Specialized Four-Digit Numbers
- zoj 计算子矩阵的平方和
- ZOJ 1842 Prime Distance(素数筛选法2次使用)
- switch case语句的使用
- 1622-5 孔富晨 总结《2016年12月30日》 【连续第91天天总结】