Kod: Zaznacz cały
#include<iostream>
#include<cmath>
using namespace std;
int NWD (int a, int b)
{ while (a>0)
{a=a%b;
b=b-a;
}
return b;
}
int NWW (int a, int b, int n)
{ return (a*b)/n;
}
int main()
{ int n;
int i;
int a;
int t1;
int t2;
int suma;
int iloczyn;
int ile;
int min;
int max;
int parzysta;
int nieparzysta;
int nww;
int nwd;
int podz;
double sr;
suma=0;
iloczyn=1;
ile=0;
podz=0;
for (i=0; i<5; i++)
{ cin>>a;
if (i==0) t1=a;
if (i==1) t2=a;
if (min==0) min=a;
if (max==0) max=a;
suma=a+suma;
sr=(double)suma/5;
iloczyn=a*iloczyn;
if (a%7==0)ile=ile+1;
if (a<min) min=a;
if (a>max) max=a;
if (a%2==0) parzysta=a;
if (a%2==1) nieparzysta=a;
if (a%5==0) podz=podz+1;
}
nwd=NWD(t1,t2);
nww=NWW(t1,t2,nwd);
cout<<"parzysta"<<endl<<parzysta<<endl;
cout<<"nieparzysta"<<endl<<nieparzysta<<endl;
cout<<"suma"<<endl<<suma<<endl;
cout<<"iloczyn"<<endl<<iloczyn<<endl;
cout<<"min"<<endl<<min<<endl;
cout<<"max"<<endl<<max<<endl;
cout<<"srednia"<<endl<<sr<<endl;
cout<<"nwd"<<endl<<nwd<<endl;
cout<<"nww"<<endl<<nww<<endl;
cout<<"podzielne przez 7"<<endl<<ile<<endl;
cout<<"podzielne przez 5"<<endl<<podz<<endl;
system("pause");
return 0;
}