Viết ct tính tổng T= 1/3+1/4+1/5…+1/20 viết ct tính tích S= 10 * 11* 12*-*n 22/07/2021 Bởi Samantha Viết ct tính tổng T= 1/3+1/4+1/5…+1/20 viết ct tính tích S= 10 * 11* 12*….*n
a) program tinhtong_T; uses crt; var t:int64; i:byte; begin clrscr; t:=0; for i:=3 to 20 do t:=t+1/i; write(‘T= ‘,t:2:2); readln; end. b) program tinhtich; uses crt; var n,i:byte; s:int64; begin clrscr; write(‘Nhap n: ‘); readln(n); s:=0; for i:=10 to n do s:=s+i; write(‘S= ‘,s); readln end. Bình luận
T= 1/3+1/4+1/5…+1/20 uses crt;var i:longint; t:real;beginclrscr; t:=0; for i:=3 to 20 do t:=t+1/i; writeln(‘T= ‘,t:0:3);readlnend. S= 10 * 11* 12*….*n uses crt;var i,s,n:longint; beginclrscr; write(‘Nhap n: ‘);readln(n); s:=1; for i:=10 to n do s:=s*i; writeln(‘S= ‘,s);readlnend. Bình luận
a)
program tinhtong_T;
uses crt;
var t:int64;
i:byte;
begin
clrscr;
t:=0;
for i:=3 to 20 do
t:=t+1/i;
write(‘T= ‘,t:2:2);
readln;
end.
b)
program tinhtich;
uses crt;
var n,i:byte;
s:int64;
begin
clrscr;
write(‘Nhap n: ‘); readln(n);
s:=0;
for i:=10 to n do
s:=s+i;
write(‘S= ‘,s);
readln
end.
T= 1/3+1/4+1/5…+1/20
uses crt;
var i:longint; t:real;
begin
clrscr;
t:=0;
for i:=3 to 20 do t:=t+1/i;
writeln(‘T= ‘,t:0:3);
readln
end.
S= 10 * 11* 12*….*n
uses crt;
var i,s,n:longint;
begin
clrscr;
write(‘Nhap n: ‘);readln(n);
s:=1;
for i:=10 to n do s:=s*i;
writeln(‘S= ‘,s);
readln
end.