va rooog urgeent orice raspuns e bine venit
Răspunsuri la întrebare
Toate programele au fost testate cu succes.
Ex. 1)
#include <iostream>
using namespace std;
int main()
{
int n,x,M=0,d=0,i;
cin>>n;
for(i=1;i<=n;i++)
{
cin>>x;
if(x>0)
{
d++;
M=M+x;
}
}
if(d==0)
{
cout<<"Nu exista";
}
else
{
cout<<M/d;
}
}
Ex.2)
#include <iostream>
using namespace std;
int main()
{
int x,max=0;
while(x!=0)
{
cin>>x;
if(max<x)
{
max=x;
}
}
cout<<max;
}
Ex.3)
#include <iostream>
using namespace std;
int main()
{
double n,i,P=1;
cin>>n;
for(i=2;i<=n;i++)
{
P*=1/i;
}
cout<<P;
}
Ex.4)
#include <iostream>
using namespace std;
int main()
{
int n,par=0,impar=0;
cin>>n;
while(n!=0)
{
if(n%10%2==0)
{
par++;
}
else
{
impar++;
}
n=n/10;
}
cout<<"Nr. pare: "<<par<<";"<< "Nr. impare: "<<impar;
}