# Untitled

unknown
plain_text
2 years ago
1.8 kB
8
Indexable
Never
```// Zadatak1 - a
#include<iostream>
using namespace std;
bool prost(int a)
{
for (size_t i = 2; i < a; i++)
{
if (a % i == 0)
return false;
}
return true;
}

bool sortiran(int a)
{

while (a)
{
if (a % 10 < a / 10 % 10)
return false;
a /= 10;
}
return true;
}

int main()
{
int a;
while (cout << "unesite broj\t", cin >> a, a < 2 || a>1000);
for (size_t i = 2; i < a; i++)
{
if (prost(i)&&sortiran(i))
cout << i<<" ";
}
cin.get();
return 0;
}

#include<iostream>
using namespace std;
int brojcifara(int a)
{
int brojac = 0;
while (a)
{
a /= 10;
brojac++;
}
return brojac;
}
bool validan(int a)
{
while (a)
{
int c = a % 10;
if (c!= 0 || c!= 1)
return false;
a /= 10;
}
return true;
}
int operacija(int b1, int b2)
{
int nb = 0, b = 0, brojac=0;
while (b1)
{

int c1 = b1 % 10;
int c2 = b2 % 10;

if (c1 == c2) b = 1;
else if (c1 > c2 || c1 < c2)b = 0;
nb += b * pow(10, brojac);
brojac++;

b1 /= 10;
b2 /= 10;
}
return nb;
}
int main()
{
int nd, b1, b2;
while (cout << "Unesite ukupan broj cifara\t", cin >> nd, nd <= 0);
do
{
cout << "Unesite b1\t ";
cin >> b1;

} while (brojcifara(b1)!=nd && validan(b1)==false);
do
{
cout << "Unesite b2\t ";
cin >> b2;
} while (brojcifara(b2) != nd && validan(b2)==false);
cout << "Rezultat " << operacija(b1, b2) << endl;
cin.get();
return 0;
}
```