Thứ Sáu, 4 tháng 12, 2015

Đề thi Học Kỳ CNTT Bến Tre năm 1 câu 2 ...

Cau02
Image

 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
#include <stdio.h>
#include <conio.h>
#include <math.h>

void main()
{
    float n, a;
    do
    {
        printf("\nEnter a: ");
        scanf("%f", &a);
        printf("\nEnter n: ");
        scanf("%f", &n);
        if(n < 1 || a < 1)
        {
            printf("Try enter n >= 1 or a >= 1");
        }
    }while(n < 1 || a < 1);
    float gt = 1, S = 0, i = 1, j = n;
    while(i <= n)
    {
        gt = gt * i;
        S = sqrt(gt / pow(a, j) + S);
        i++;
        j--;
    }
    printf("\nS = %f", S);
    getch();
}
004