Bài 40: Tính S(n) = CanBac2(x^n + CanBac2(x^n-1 + … + CanBac2(x^2 + CanBac2(x)))) có n dấu căn

Bài 40: Tính S(n) = CanBac2(x^n + CanBac2(x^n-1 + … + CanBac2(x^2 + CanBac2(x)))) có n dấu căn

Bài tập 40 (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) = CanBac2(x^n + CanBac2(x^n-1 + … + CanBac2(x^2 + CanBac2(x)))) có n dấu căn

S(n) = xn + xn - 1 + xn - 2 + ... x2 + x

có n dấu căn

Cài đặt

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int i, n;
    float x, T, S;
    i = 1;
    T = 1;
    S = 0;
    do
    {
    printf("\nNhap x(x >= 0): ");
    scanf("%f", &x);
      if(x < 0)
      {
          printf("\nx khong hop le. Xin nhap lai !");
      }
    }while(x < 0);
    do
    {
    printf("\nNhap n(n >= 1): ");
    scanf("%d", &n);
    if(n < 1)
      {
          printf("\nn khong hop le. Xin nhap lai !");
      }
    }while(n < 1);
    while(i <= n)
    {
        T = T * x;
        S = sqrt(T + S);
        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 (3 votes)
Ả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

 
Sức mạnh của Contextual Filters trong Drupal Views của Drupal 8

Sức mạnh của Contextual Filters trong Drupal Views của Drupal 8

The small endpoint I built returns an array of cars in sale, with relative information about each car

Tự động tạo tiêu đề trong Drupal với Node Titles.module

Tự động tạo tiêu đề trong Drupal với Node Titles.module

There are many possible reasons to replace the title, but most of them come down to this ... the title field is not very flexible.

thu tinh trong ong nghiem

Mang thai sau khi thụ tinh trong ống nghiệm/thụ tinh nhân tạo: điều ba mẹ cần biết.

Hiện nay có 2 phương pháp điều trị vô sinh chính được áp dụng nhiều nhất tại Việt Nam.

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

 

Diet con trung