You are on page 1of 5

Probleme

1. #include <iostream>
using namespace std;
int main()

{
int n,i=0,v[50],r,x;

cout<<"n=";
cin>>n;

for(i=0;i<n;i++) {
cin>>v[i];

r=v[i]-v[0]; x=1;

for(i=2;i<n;i++)

if(v[i]-v[i-1]!=r) x=0;
if(x) cout<<"elem sunt in prog aritmetica";
else cout<<"elem nu sunt in prog aritmetica";
return 0;
}
2. //determinarea a celui mai mare divizor comun//
#include <iostream>
using namespace std;

int main(){

int n;
cout<<"n=";
cin>>n;

int v[50];
int i;
for (i = 1; i <= n; i++)
cin>>v[i];

int cmmdc = v[1];


for (i = 2; i <= n; i++){

int x = v[i];
while (x != cmmdc){

if (x > cmmdc)
x = x - cmmdc;
else if (x < cmmdc)
cmmdc = cmmdc - x;
}
}

cout<<cmmdc;

return 0;

}
3. //cel mai mic multiplu comun//
#include <iostream>
using namespace std;

int main(){

int n;
cout<<"n=";
cin>>n;

int v[100];
int i;
for (i = 0; i <n; i++)
cin>>v[i];

int cmmmc = v[1];


for (i = 2; i <= n; i++){
int y = cmmmc,x = v[i];
while(y != x){
if (y > x)
y = y - x;
else if (x > y)
x = x - y;

cmmmc = cmmmc*(v[i]/x);

cout<<cmmmc;

return 0;

}
4. // numar par//
#include <iostream>
using namespace std;

int main(){

int n;
cout<<"n=";
cin>>N;

int v[50];
int i;

for (i = 0; i < n ; i++)


cin>>v[i];

for (i = 0; i < n; i++)


if (v[i] % 2 == 0)
cout<<v[i]<<" ";
return 0;
}

You might also like