Bài 22 : Viết hàm tính S = (1*2!)/(2+sqrt(3)) + (2*3!)/(3+sqrt(4)) + (3*4!)/(4+sqrt(5)) + ... + (n*((n+1)!))/((n+1)+sqrt(n+2)) .Dùng vòng lặp
Tải code tại đây
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| /* Bài 22:Viết hàm tính S = (1*2!)/(2+sqrt(3)) + (2*3!)/(3+sqrt(4)) + (3*4!)/(4+sqrt(5)) + ... + (n*((n+1)!))/((n+1)+sqrt(n+2)) . 617.cpp */
// Các thư viện sử dụng trong chương trình .
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<Windows.h>
// Hàm nhập vào số n .
void NhapN(int &n)
{
quaylai:printf("\nNhap vao n=");
scanf("%d",&n);
if(n<1)
{
printf("\nSo ban nhap vao khong hop le!Xin vui long nhap lai!");
goto quaylai;
}
}
// Hàm xử lý dữ liệu .
void XuLyDuLieu(int n)
{
float s=0;
float sqrt(float x); // Khai báo định dạng của sqrt .
for(int i=1;i<=n;i++)
{
int s1=1;
for(int j=1;j<=i+1;j++)
{
s1*=j;
}
s+=(i*s1)/((i+1)+sqrt(i+2));
}
printf("\nKet qua la:%f",s);
}
// Hàm chính .
void main()
{
int n,tieptuc;
quaylai:NhapN(n);
XuLyDuLieu(n);
printf("\n");
printf("\nBan co muon tiep tuc thuc hien chuong trinh hay khong ? Neu co bam phim C,nguoc lai bam bat ky 1 phim nao khac de ket thuc!");
tieptuc=getch();
if(tieptuc=='c'||tieptuc=='C')
{
system("cls");
goto quaylai;
}
}
|
edc titanium, aces steel, nickel, black - TITanium
Trả lờiXóaThe gold-plated brass core 2017 ford fusion energi titanium of the edc core. Solid brass core for corrosion resistant material. Includes a titanium flask gold core for corrosion titanium plumbing resistant Rating: 4 · 2018 ford fusion energi titanium 7 reviews · titanium hair clipper $50.00 · In stock