Admins Thái Thượng Hoàng
Tổng số bài gửi : 336 Age : 35 Đến từ : cát bụi Registration date : 03/04/2008
| Tiêu đề: BÀI TẬP CÁC CT CON Wed Apr 23, 2008 7:23 pm | |
| - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double TongS24A(int n); //============================ void main() { int n; char ch; double s=0; do { printf("\n\t CT Tinh Tong S=1+2+3+...+n"); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); s=TongS24A(n); printf("\n\t Neu N=%d,Thi Ket Qua S=%14.0f",n,s); printf("\n\t Ban Co Muon Tie1p Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double TongS24A(int n) { double s=0; for(int i=1;i<=n;i++) s+=i; return s; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double GT24B(int n); //============================ void main() { int n; char ch; double gt=1; do { printf("\n\t CT Tinh GT S=n!"); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); gt=GT24B(n); printf("\n\t Neu N=%d,Thi Ket Qua S=%14.0f",n,gt); printf("\n\t Ban Co Muon Tie1p Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double GT24B(int n) { double gt=1; for(int i=1;i<=n;i++) gt*=i; return gt; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double LT24C(int n,int x); //============================ void main() { int n,x; char ch; double lt=1; do { printf("\n\t CT Tinh GT S=n!"); printf("\n\t Moi Nhap Gia Tri X:"); scanf("%d",&x); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); lt=LT24C(n,x); printf("\n\t Neu X=%d,N=%d,Thi Ket Qua S=%14.0f",x,n,lt); printf("\n\t Ban Co Muon Tiep Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double LT24C(int n,int x) { double lt=1; for(int i=1;i<=n;i++) lt*=x; return lt; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double GT24D(int n); //============================ void main() { int n; char ch; double s=1,gt=1; do { printf("\n\t CT Tinh GT S=1+3!+5!+....(2*n+i)!!"); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); s=GT24D(n); printf("\n\t Neu N=%d,Thi Ket Qua S=%14.0f",n,s); printf("\n\t Ban Co Muon Tie1p Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double GT24D(int n) { double s=1,gt=1; for(int i=1;i<=n;i++) { gt=gt*(2*i)*(2*i+1); s=s+gt; } return s; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double LT24E(int n,int x); //============================ void main() { int n,x; char ch; double lt=x,s=x; do { printf("\n\t CT Tinh GT S=X+X^3+X^5+....+X^(2*n+i)"); printf("\n\t Moi Nhap Gia Tri X:"); scanf("%d",&x); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); lt=LT24E(n,x); printf("\n\t Neu X=%d,N=%d,Thi Ket Qua S=%14.0f",x,n,lt); printf("\n\t Ban Co Muon Tiep Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double LT24E(int n,int x) { double lt=x,s=x; for(int i=1;i<=n;i++) { lt=lt*x*x; s=s+lt; } return s; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double GT24F(int n); //============================ void main() { int n; char ch; double s=1,gt=1; do { printf("\n\t CT Tinh GT S=1-3!+5!+....(-1)*(2*n+i)!!"); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); s=GT24F(n); printf("\n\t Neu N=%d,Thi Ket Qua S=%14.0f",n,s); printf("\n\t Ban Co Muon Tie1p Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double GT24F(int n) { double s=1,gt=1; int d=-1; for(int i=1;i<=n;i++) { gt=gt*(2*i)*(2*i+1); s=s+d*gt; d=-d; } return s; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double LT24G(int n,int x); //============================ void main() { int n,x; char ch; double lt=x,s=x; do { printf("\n\t CT Tinh GT S=X-X^3+X^5+....+(-1)*X^(2*n+i)"); printf("\n\t Moi Nhap Gia Tri X:"); scanf("%d",&x); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); lt=LT24G(n,x); printf("\n\t Neu X=%d,N=%d,Thi Ket Qua S=%14.0f",x,n,lt); printf("\n\t Ban Co Muon Tiep Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double LT24G(int n,int x) { int d=-1; double lt=x,s=x; for(int i=1;i<=n;i++) { lt=lt*x*x; s=s+d*lt; d=-d; } return s; } - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double T24H(int n,int x); //============================ void main() { int n,x; char ch; double lt=x,s=x,gt=1; do { printf("\n\t CT Tinh GT S=X-X^3/3!+X^5/5!+....+(-1)*X^(2*n+i)/(2*n+i)!"); printf("\n\t Moi Nhap Gia Tri X:"); scanf("%d",&x); printf("\n\t Moi Nhap Gia Tri N:"); scanf("%d",&n); s=T24H(n,x); printf("\n\t Neu X=%d,N=%d,Thi Ket Qua S=%f",x,n,s); printf("\n\t Ban Co Muon Tiep Tuc Hok (C/K)"); ch=getch(); } while((ch=='C')||(ch=='c')); getch(); } //================================= double T24H(int n,int x) { double lt=x,s=x,gt=1; for(int i=1;i<=n;i++) { lt=lt*x*x; gt=gt*(2*i)*(2*i+1); s=s+lt/gt;
} return s; }
Được sửa bởi Admin ngày Thu Apr 24, 2008 7:20 pm; sửa lần 2. | |
|
Tony Feung Nhà phân phối... Tình Yêu
Tổng số bài gửi : 34 Age : 35 Registration date : 04/04/2008
| Tiêu đề: Re: BÀI TẬP CÁC CT CON Wed Apr 23, 2008 9:31 pm | |
| lưu ý Tong S phải viết liền vô ko dc viết cách ra => vầy mới đúng TongS... những cái khác cũng vậy | |
|
Admins Thái Thượng Hoàng
Tổng số bài gửi : 336 Age : 35 Đến từ : cát bụi Registration date : 03/04/2008
| Tiêu đề: Re: BÀI TẬP CÁC CT CON Sun Apr 27, 2008 11:35 pm | |
| - Code:
-
#include<conio.h> #include<stdio.h> #include<math.h> double Sinx(int x); //============================== void main() { char ch; int x,i,d; double gt,gt1,lt,lt1; long n; float sin,dk; do { printf("\n\t CT Tinh Goc Sin X"); printf("\n\t Moi Nhap Goc X:"); scanf("%d",&x); sin=Sinx(x); printf("\n\t Neu GT=%f,LT=%f,Thi dk=%14.0f",gt,lt,dk); printf("\n\t Neu X=%d,Thi SinX=%14.12f",x,sin); printf("\n\t Ban Co Muon Tiep Tuc Hok (C/K):"); ch=getch(); } while((ch=='c')||(ch=='C')); getch(); } //================================= double Sinx(int x) { int i,d; double gt,gt1,lt,lt1; long n; float sin,dk; lt = x; gt = 1; n = 1; dk = x; while(dk >= 0.00001) { n = n + 1; lt = lt * x; gt = gt * n; dk = lt / gt; } lt1 = x; gt1 = 1; sin = x; d = -1; for (i = 1; i <= n; i++) { lt1 = lt1 * x * x; gt1 = gt1 * (2 * i) * (2 * i + 1); sin = sin + d * lt1/gt1; d = -d; } return sin; } | |
|
Sponsored content
| Tiêu đề: Re: BÀI TẬP CÁC CT CON | |
| |
|