Va rog mult, ma puteți ajuta la orice problema din acestea? Va rog, orice ajuta.
Răspunsuri la întrebare
Răspuns:
Explicație:
16.
#include <iostream>
using namespace std;
int v[100], n, m=0, i;
int main ()
{
cout<<"Cate numere are sirul?"<< std::endl;
cin >>n;
for (i=1;i<=n;i++)
{
cout <<"v["<<i<<"]=";
cin >>v[i];
}
for (i=1;i<n;i++)
{
if (v[i] == v[i+1])
{
m++;
}
}
cout<<"Numarul elementelor consecutive egale intre ele: "<<m;
return 0;
}
17.
#include <iostream>
using namespace std;
int v[100], i, n, d;
int main()
{
cout<<"Cate numere are sirul?"<< std::endl;
cin >>n;
for (i=1;i<=n;i++)
{
cout <<"v["<<i<<"]=";
cin >>v[i];
}
for (i=1;i<=n;i++)
{
int x=0;
for(d=2; d<=v[i]/2; d++)
if(v[i]==1 || v[i]%d==0)
x++;
if(x==0)
cout<<v[i]<<" ";
}
return 0;
}
18.
#include <iostream>
using namespace std;
int n, m=0, i;
float v[100];
int main ()
{
cout<<"Cate numere are sirul?"<< std::endl;
cin >>n;
for (i=1;i<=n;i++)
{
cout <<"v["<<i<<"]=";
cin >>v[i];
}
for (i=1;i<n-1;i++)
{
if (v[i+1] == (v[i]+v[i+2])/2)
{
m++;
cout <<v[i]<<" "<<v[i+1]<<" "<<v[i+2]<< std::endl;
}
if (m==0)
{
cout <<"Sirul nu indeplineste conditiile.";
}
}
return 0;
}