Bài tập 15: Tính S(n) = 1 + 1/1 + 2 + 1/ 1 + 2 + 3 + ….. + 1/ 1 + 2 + 3 + …. + N

Bài tập 15: Tính S(n) = 1 + 1/1 + 2 + 1/ 1 + 2 + 3 + ….. + 1/ 1 + 2 + 3 + …. + N

Bài tập 15 (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) = 1 + 1/1 + 2 + 1/ 1 + 2 + 3 + ….. + 1/ 1 + 2 + 3 + …. + N

Cài đặt

#include<stdio.h>
#include<conio.h>

int main()
{
    int i, n;
    float S, T;
    i = 1;
    S = 0;
    T = 0;
    do
    {
    printf("\nNhap n: ");
    scanf("%d", &n);
      if(n < 1)
       {
        printf("\nN phai >= 1. Xin Nhap lai!");
       }
    }while(n < 1);

    while(i <= n)
    {
        T = T + i;
        S = S + 1.0 / 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: 9 (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

 
D8 to D3: Using Drupal for data visualization

D3 JavaScript library : Làm Drupal for data visualization

One of the exciting features that’s on its way in Drupal 8 is the ability to use Drupal as a RESTful web service. This means that Drupal 8 core allows you to expose data to external applications in a number of standardized formats

Giới thiệu top 10 Drush commands tiếp theo

Giới thiệu top 10 Drush commands tiếp theo

Here is the top 10 Drush commands from the fine folk who contributed (in some cases, they are variations of a command that I listed in my post).

Android

Thị trường ưa chuộng Android hơn Windows Phone

Sau vụ kiện Samsung - Apple đình đám mà nạn nhân gián tiếp là Android, một số hãng smartphone Android đang tìm phương án thay thế dù vẫn tuyên bố gắn bó với nền tảng của Google.

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

 

Diet con trung