VAAA ROGG ESTE URGEEENT!!!
Răspunsuri la întrebare
Răspuns:
1)
#include <iostream>
using namespace std;
int main()
{
int n,i,j,nr,S=0;
cout<<"n=";
cin>>n;
for(i=2;i<=n;i++)
if(n%i==0)
{
nr=0;
for(j=2;j<i;j++)
if(i%j==0)
nr++;
if(nr==0)
S=S+i;
}
cout<<S;
return 0;
}
2)
#include <iostream>
using namespace std;
int main()
{
float n,m,S1=0,S2=0,i;
cout<<"n=";
cin>>n;
cout<<"m=";
cin>>m;
if(n>m)
{
for(i=1;i<=n;i++)
{
S1=S1+(i*(i+1));
S2=S2+n+i;
}
S1=S1/S2;
cout<<S1;
S2=0;
for(i=2;i<=n;i++)
S2=S2+(1-(1/i));
cout<<" "<<S2;
}
else if(n==m)
{
for(i=1;i<=n;i++)
S1=S1+(1/(i*(i+1)));
cout<<S1;
}
return 0;
}
3)
a)10
b)
#include <iostream>
using namespace std;
int main()
{
int a,b,k=0,i,n,c;
cout<<"a=";
cin>>a;
cout<<"b=";
cin>>b;
for(i=a;i<=b;i++)
{
n=1;
c=0;
while(n>0)
{
if(n%2==1)
c++;
n=n/10;
}
if(c>0)
k++;
}
cout<<k;
return 0;
}
Explicație:
Multumesc+5 stele+cel mai inteligent raspuns?