Răspuns :
problema1
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int n, i;
double minim, maxim, mediageo, num;
cin >> n;
cin >> num;
minim=num; maxim=num;
for (i=2; i<=n; ++i)
{
cin >> num;
if (num<minim) minim=num;
if (num>maxim) maxim=num;
}
mediageo=sqrt(minim*maxim);
cout << mediageo;
return 0;
}
problema 2:
#include <iostream>
using namespace std;
float a[100];
int main()
{
int n, i, nr=0;
cin >> n;
for (i=1; i<=n; ++i)
cin >> a[i];
float st=a[1], dr=a[n];
if (st>dr) swap(st, dr);
for (i=2;i<n; ++i )
if (a[i]>=st && a[i]<=dr) ++nr;
cout << nr;
return 0;
}
problema 3:
#include <iostream>
using namespace std;
int v[100];
int main()
{
int n, k, i, gasit=0;
cin >> n >> k;
for (i=1; i<=n; ++i)
cin >> v[i];
for (i=1; i<=n; ++i)
if (v[i]==k) { gasit=1; break; }
if (gasit) cout << "EXISTA";
else cout << "NU EXISTA";
return 0;
}
problema 4:
#include <iostream>
using namespace std;
int v[100];
int main()
{
int n, i, perechi=0;
cin >> n ;
for (i=1; i<=n; ++i)
cin >> v[i];
for (i=1; i<n; ++i)
if (v[i]==v[i+1]) { ++perechi; }
cout << perechi;
return 0;
}