Bải tập 14: Tính S(n) = x + x^3 + x^5 + … + x^2n + 1

Bải tập 14: Tính S(n) = x + x^3 + x^5 + … + x^2n + 1

Bài tập 14 (Dạng bài tập này giúp các bạn giỏi về: Lưu đồ thuật toán)

Tính S(n) = x + x^3 + x^5 + … + x^2n + 1

Cài đặt

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int i, n;
    float x, T, S;
    i = 0;
    T = 1;
    S = 0;
    printf("\nNhap x: ");
    scanf("%f", &x);

    printf("\nNhap n: ");
    scanf("%d", &n);

    while(i < n)
    {
        T = pow(x, (2 * i + 1));
        S = S + T;
        i++;
    }

    printf("\nTong la %f",S);

    getch();
    return 0;
}
Bạn thấy bài viết này như thế nào?: 
Average: 10 (1 vote)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Hướng dẫn Embedding Responsive iframes trong Drupal site

Hướng dẫn Embedding Responsive iframes trong Drupal site

Implementing iframe elements can be troublesome for both content editors and developers, that's even before trying to make them responsive. After some recent project work I'm here to tell you there is an easy way to handle them.

nuoi con bang sua me

Nuôi con bằng sữa mẹ và lợi ích của việc nuôi con bằng sữa mẹ.

Tất cả chúng ta đều biết sữa mẹ là nguồn dinh dưỡng tốt nhất cho trẻ sơ sinh và trẻ nhỏ. Đây là loại thức ăn hoàn hảo để trẻ sơ sinh phát triển toàn diện. Trong sữa mẹ có chứa các chất đề kháng và dưỡng chất, các chất này đáp ứng đầy đủ các nhu cầu thay đổi của bé và bảo vệ bé khỏi viêm nhiễm và bệnh tật.

Drupal 7 Form API: Sử dụng #states cho multiple conditionals (AND, OR and XOR)

Drupal 7 Form API: Sử dụng #states cho multiple conditionals (AND, OR and XOR)

If you have a simple, one off case where you have a conditional field and are reluctant to introduce 2-3k lines of code, you can use hook_form_alter() and #states API.

Công ty diệt chuột T&C

 

Diet con trung