Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
program TT;
uses CRT;
Var i,n:integer;
P:longint; S:Real;
begin
Write('Nhap N: '); Readln(N);
S:=0;
P:=1;
For i:=1 to N do
begin P:=P*i; S:=S+1/P; end;
Writeln('Tong S= ',S:5:3);
Readln
End.
Câu 1:
uses crt;
var a:array[1..10]of integer;
i,n,k,t:integer;
begin
clrscr;
write('nhap n='); readln(n);
if (0<n) and (n<=10) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap k='); readln(k);
{----------------------------cau-a-------------------------}
writeln('cac phan tu lon hon hoac bang ',k,' trong day la: ');
for i:=1 to n do
if a[i]>=k then write(a[i]:4);
{--------------------------cau-b-------------------------------}
writeln;
t:=0;
for i:=1 to n do
if a[i]>=k then t:=t+a[i];
writeln('tong cac phan tu lon hon hoac bang ',k,' la: ',t);
end
else writeln('vui long nhap lai');
readln;
end.
Câu 2:
uses crt;
var a:array[1..10]of integer;
i,n,tam,j,k:integer;
begim
clrscr;
write('nhap n='); readln(n);
if (0<n) and (n<=10) then
begin
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('nhap k='); readln(k);
writeln('Day truoc khi sap xep la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('day sap xep tang dan la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
writeln('day sap xep giam dan la: ');
for i:=1 to n do
write(a[i]:4);
end
else writeln('vui long nhap lai');
readln;
end.
USES CRT;
VAR A:ARRAY[1..100] OF INTEGER;
N,I:INTEGER;
S:LONGINT;
BEGIN
CLRSCR;
WRITE('NHAP SO PHAN TU: ');
READLN(N);
FOR I:=1 TO N DO
BEGIN
WRITE('A[',I,']=');
READLN(A[I]);
END;
S:=1;{VI KHI NHAN VOI 1 THI MOI RA KET QUA NHA BAN}
FOR I:=1 TO 8 DO S:=S*A[I];{CO THE THAY 8 THANH 5 DE LAM CAU 2}
WRITELN('TONG CAC PHAN TU TRONG MANG TU 1 DEN 8 LA: ',S);
READLN
END.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n,s:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
s:=0;
for i:=1 to n do
s:=s+a[i];
writeln(s);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
i,n,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.