DEDLINE 2
MIRZAYEV IBRATILLO
1-topshiriq 11-misol
n butun son berilgan (n>0). Quyidagi yig`indini hisoblash dasturini tuzing. S=1!+2!+3!+……+n!
#include
using namespace std;
int main()
{
int n, S=0, P=1;
cout << "n ni kiriting="; cin >> n;
for(int i=1; i<=n; i++)
{
P*=i;
S+=P;
}
cout << "Natija=" << S << endl;
return 0;
}
Mirzayev Ibratillo
2-topshiriq 11-misol ni hisoblang;
#include
#include
using namespace std;
int main()
{
int n, a, b;
float S=0;
cout << "n ni kiriting="; cin >> n;
cout << "a ni kiriting="; cin >> a;
cout << "b ni kiriting="; cin >> b;
int i=1;
while(i<=n)
{
S+=(i*i+pow(a,i))/b; i++;
}
cout << "Natija=" << S << endl;
return 0;
}
Mirzayev Ibratillo
1-topshiriq 11-misol
N!!=N*(N-2)*(N-4)*…… ifodani hisoblovchi haqiqiy toifadagi Fact(N) rekursiv funksiya tuzilsin;
#include
using namespace std;
int Ibratillo(int n)
{
int S=0;
if(n<0) return 0;
if(n==0) return 1;
else return n*Ibratillo(n-2);
return 0;
}
int main()
{
int n;
cout << "n ni kiriting=";cin >> n;
cout << "Natija=" << Ibratillo(n) << endl;
return 0;
}
Mirzayev Ibratillo
Do'stlaringiz bilan baham: |