Uses Crt;
Var A : Array [1..100] Of Integer ;
i , j , n , T : Integer ;
BEGIN
Clrscr ;
Write(' Do dai cua day so N = ') ; Readln (N) ;
Writeln (' Nhap day so : ') ;
For i := 1 To N Do
Begin
Write('A[', i ,'] = ') ; Readln ( A ) ;
End ;
i := 1 ;
While (i <= n-1) Do
Begin
j := i+1;
While j<=n do
Begin
If A[j] < A then
Begin
T := A[j];
A[j ] := A;
A := T ;
End ;
j := j + 1;
End ;
i := i + 1;
End ;
Writeln(' Day sau khi sap xep : ') ;
For i := 1 To N Do Write(A : 4) ;
Readln ;
END .
uses crt;
var
i,tong:integer
begin
tong:=0;
for i:=1 to 100 do
tong:=tong+i;
write(tong);
readln;
end.
uses crt;
var
i,tong:integer
begin
clrscr;
tong:=0;
i:=1
while i<0 do
begin
tong:=tong+i;
i:=i+1;
end;
write(tong);
readln;
end.
1. for....do
var i,s:integer;
begin
s:=0;
for i:=1 to 100 do s:=s+i;
writeln('tong cua 100 so tu nhien dau tien la',s);
readln
end.
2. while...do
var i,s:integer;
begin
i:=1;
s:=0;
while i<=100 do
begin
s:=s+i; i:=i+1;
end;
writeln('tong cua 100 so tu nhien dau tien la',s);
readln
end.
var i: integer;
s: longint;
begin
s:=0;
i:=1;
while i<=n do
begin
s:= s+i; i:= i+1;
end;
write('tong tu 1 den 100 la ', s);
readln
end.
2.
var i: integer;
s: longint;
begin
s:=0;
for i:=1 to 100 do s:= s+i;
writeln('tong tu 1 den 100 la: ', s);
readln
end.