首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

zoj 1622 Switch 开关灯 简略枚举

2013-10-13 
zoj 1622 Switch 开关灯 简单枚举ZOJ Problem Set - 1622#includestdio.h#includeiostream#includecs

zoj 1622 Switch 开关灯 简单枚举
ZOJ Problem Set - 1622

#include<stdio.h>#include<iostream>#include<cstring>using namespace std;int a[10005];int main(){int i,n,tempo,tempj,temp;while(scanf("%d",&n)!=EOF){memset(a,0,sizeof(a));tempo=tempj=temp=0;for(i=0;i<n;i++){scanf("%d",&a[i]);if(i%2==0){if(a[i]==1)tempj++;elsetempo++;}else{if(a[i]==0)tempj++;elsetempo++;}}if(tempj>tempo)temp=tempo;elsetemp=tempj;printf("%d\n",temp);}return 0;}

热点排行