Dedline 2 mirzayev ibratillo


Download 204.6 Kb.
Sana09.11.2021
Hajmi204.6 Kb.
#172423
Bog'liq
Mirzayev Ibratillo - dedline 2





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


Download 204.6 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling