Using Namespace Int Int Int Int For For If Return: #Include N A

You might also like

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

1.

#include <iostream>
using namespace std;
int cdif(int n, int a[])
{
int i, j;
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
if (a[j] == a[i])
return 0;
}
}
return 1;
}
int main()
{
int i, n, a[10001];
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 0; i < n; i++)
{
if (a[i] < 500 && a[i]>1000 && cdif() == 1)
cout << a[i];
}
}

2. #include <iostream>
using namespace std;
int b[1001];
int inv(int n, int a[])
{
int i, j;
for (i = 0; i < n; i++)
{
b[i] = 0;
while (a[i])
{
j = a[i] % 10;
b[j] = b[j] * 10 + a[i];
n = n / 10;
}
return b[i];

}
int main()
{
int i, n, a[10001];
for (i = 0; i < n; i++)
cin >> a[i];
for (i = 0; i < n; i++)
{
cout << inv(b[i]);
}
}
3. #include <iostream>
using namespace std;
int b[1001];
int ncifpatrate(int n)
{
int i, c,patrat;
if (n == 2 && n == 3 && n == 7 && n == 8)
return 0;
else
{
for (i = 1; i <= 1000; i++)
{
patrat = i * i;
if (patrat % 10 == n)
return patrat;

}
}
}
5. #include <iostream>
using namespace std;
int b[1001];
int par(int cif)
{
if (cif == 1 && cif == 3 && cif == 5 && cif == 7 && cif == 9)
return 0;
else return 1;

int sumcif{int n , int a[])


{
int S = 0,cif,OK;
for (i = 0; i < n; i++)
{
OK = 1;
while (a[i])
{
cif = n % 10;
if (par(cif) == 0)
OK = 0;
}
if (OK == 1)
S = S + a[i];
}
if (S == 0)
return"Nu exista numere cu toate cifrele pare"
else
return S;
}
6.
#include <iostream>
using namespace std;
int sumproddiv(int n)
{
int d ,S=0,P=1;

for (d = 2; d*d <= n; d++)


{
if (n % d == 0)
S = S + d;
P = P * d;
}
}
return S;
return P;
}
7.
#include <iostream>
using namespace std;
int sumproddiv(int n,int a,int b)
{
int S=0,ctrl=0,P=0,d;

for (d = 2; d*d <= n; d++)


{
if (n % d == 0)
{
S = S + d;
if (d > a && d < b)
{
ctrl++;
P = P + d;
}
}
}
if (ctrl > 0)
{
P = P / ctrl;
return P;
}
else
return"Nu exista divizori intre a si b";
return S;
}
8.
#include <iostream>
using namespace std;
int sumproddiv(int n, int a, int b)
{
int ctrl = 0, d, i, OK=1;

for (d = 2; d * d <= n; d++)


{
if (n % d == 0)
{
for (i = 2; i * i <= d; i++)
{
if (d % i == 0)
OK = 0;
}
if(OK==1)
ctrl++:
}
}
return ctrl;
}

You might also like