Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Drugi:

Kod:
#include <iostream>
using namespace std;
int main()
{
int a, p, d, t;
cin >> a;
p=a/100;
d=(a%100)/10;
t=a%10;
cout << "Suma cifara je " << p+d+t;

system("PAUSE");
}

Treci:
Kod:
#include <iostream>
using namespace std;
int main()
{
int x, y;
cin >> x;
if (x<2) y=x+2;
else if (x>=2 && x<5) y=(3*x+1)/2;
else y=x*x;
cout << y;
system("PAUSE");
}

Cetvrti:
Kod:
#include <iostream>
using namespace std;
int main()
{
int a, b, max;
cin >> a >> b;
if (a>b) max=a;
else max=b;
cout << max;

system("PAUSE");
}

Peti:
Kod:
#include <iostream>
using namespace std;
int main()
{
int plata;
double porez;
cin >> plata;
if (plata>1000) porez=0.2*plata;
else porez=0.15*plata;
cout << "Porez na platu je " << porez;
system("PAUSE");
}

Sesti:
Kod:
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Unestie duzinu niza: ";
cin >> n;
cout << "Unesite elemente niza\n";
int a[n], i, sumpar=0, brpr=0, brnul=0;
for (i=0;i<n;i++)
{
cin >> a[i];
if (a[i]%2==0) sumpar+=a[i];
if (a[i]==0) brnul++;
}
cout << "Suma parnih brojeva u nizu je " << sumpar << endl;
cout << "Broj nula u nizu je " << brnul << endl;
cout << "Elementi niza koji su pozitivni:\n";
for (i=0;i<n;i++)
if (a[i]>0)
cout << a[i] << " ";
system("PAUSE");
}

You might also like