Pagini recente » Cod sursa (job #1530185) | Cod sursa (job #1009621) | Cod sursa (job #657776) | Statistici Cotoi Rares (CotoiRares) | Cod sursa (job #2626744)
#include<fstream>
using namespace std;
ifstream fin("elmaj.in");
ofstream fout("elmaj.out");
int main()
{
int n,nCopy;
int i=1,j,x;
int elMaj,cntAppearance=0;
fin>>n;
while(i<=n/2+1)
{
for(j=1;j<=i;j++)
fin>>elMaj;
ifstream fin("elmaj.in");
fin>>nCopy;
for(j=1;j<=nCopy;j++)
{
fin>>x;
if(x==elMaj)
cntAppearance++;
}
if(cntAppearance>=n/2+1)
{
fout<<elMaj<<" "<<cntAppearance;
return 0;
}
i++;
}
fout<<-1;
return 0;
}