Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

// Subiectul al III-lea

//1.
#include <iostream>
using namespace std;

void rigola(int n, int a[], int lm, int nrap)


{
int i, max = 0;
for (i = 0; i < n; i++)
{
if (a[i] == a[i + 1] && a[i] == a[i + 2] && a[i] != a[i + 3])
nrap++;
if (a[i] == a[i + 1] || a[i] == a[i - 1])
max++;
if (lm < max)
{
lm = max;
max = 0;
}
}
cout << lm << " " << nrap;
}
int main()
{
int n, a[100], i, lm, nrap;
cin >> n;
for (i = 0; i < n; i++)
cin >> a[i];
lm = 0;
nrap = 0;
rigola(n, a, lm, nrap);
return 0;
}

//3.
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
ofstream f("tombola.out");
int x, i, s[501], nr = 0;
s[1] = 1;
cin >> x;
if (x == 1)
f << "Ai castigat";
else
{
for (i = 2; i < 501; ++i)
{
if (i % 2 == 0)
s[i] = (i - 1) * (i - 1) + 3;
else
s[i] = s[i - 1] + 1;
if (s[i] == x)
nr++;
}
if (nr != 0)
f << "Ai castigat";
else
f << "Necastigator";
}
f.close();
return 0;
}

You might also like