Cod sursa(job #675331)
Utilizator | Data | 7 februarie 2012 15:40:34 | |
---|---|---|---|
Problema | Elementul majoritar | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream>
using namespace std;
ifstream f("elmaj.in");
ofstream g("elmaj.out");
int main()
{
int long s[500],contor=0,i,j,n;
f>>n;
for(i=1;i<=n;i++)
f>>s[i];
for(j=1;j<=9;j++)
if(s[i]==j)
contor++;
if(contor==(n/2)+1)
g<<j<<" "<<contor;
return 0;
}