您的位置:首页 > 其它

hdu 1029 Ignatius and the Princess IV

2012-12-18 12:09 495 查看
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1029

题目主要意思是:有奇数个数,这些数只由两个数据组成,求其中最多个数的数据,输出即可!

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,i;
int number;		//用来标记目前最多数的数据
int t;			//输入的数据
int count;		//用来计数
while(scanf("%d",&n)!=EOF)
{
count = 0;
if(n%2 == 0)
break;
for(i = 0; i < n; i++)
{
scanf("%d",&t);
if(count == 0)
{
count = 1;
number = t;
}
else
{
if(t == number)
count++;
else
count--;
}
}
printf("%d\n",number);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: