Dau 100 de puncte
+COROANĂĂĂĂĂ
Răspunsuri la întrebare
Răspuns:
1.
#include <iostream>
using namespace std;
int main ()
{
int n, i, a, s;
cin>>n;
i=1;
s=0;
while (i<=n)
{
cin>>a;
s=s+a;
i++;
}
cout<<s;
return 0;
}
2.
#include <iostream>
using namespace std ;
int main ()
{
int n, i, p, a;
cin>>n;
i=1;
p=1;
while (i<=n)
{
cin>>a;
if (a%2==0)
p=p*a;
i++;
}
cout<<p;
return 0;
}
3.
#include <iostream>
using namespace std;
int main ()
{
int a, n, i, s;
cin>>n;
i=1;
s=0;
while (i<=n)
{
cin>>a;
if (a%2!=0)
s=s+a;
i++;
}
cout<<s;
return 0;
}
4.
#include <iostream>
using namespace std;
int main ()
{
int a, s, n, i;
cin>>n;
s=0;
i=1;
while (i<=n)
{
cin>>a;
s=s+a;
i++;
}
cout<<s/n;
return 0;
}
5.
#include <iostream>
using namespace std;
int main ()
{
int a, s, n, i, nr;
cin>>n;
s=0;
nr=0;
i=1;
while (i<=n)
{
cin>>a;
if(a%3==0)
{
s=s+a;
nr++;
}
i++;
}
cout<<s/nr;
return 0;
}