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.
* Sử dụng For ... do
Var i,s:integer;
Begin
For i:=1 to 10 do
s:=s+i;
Write('Tong la ',s);
Readln;
End.
* Sử dụng While ... do
Var i,s:integer;
Begin
i:=1;
While i<=10 do
Begin
s:=s+i;
i:=i+1;
End;
Write('tong la ',s);
Readln;
End.
Program tinhtong;
var: i,s:=longint;
Begin
i:=-1;
While i<50 do
Begin
i:=i+2;
S:=S+i;
End;
readln;
End.
Bài 1:
uses crt;
var n,i:integer;
s:real;
begin
clrscr;
write('Nhap n='); readln(n);
s:=1;
for i:=1 to n do
s:=s*i;
writeln(n,'!=',s:0:0);
readln;
end.
1).
program oken;
uses crt;
var n,i: integer;
gt: qword;
begin
write('nhap n: '): readln(n);
gt:=1;
for i:=1 to n do gt:=gt*i;
writeln('N!=',gt);
readln;
end.
2).
program tongcacsole;
uses crt;
var t,i:longint;
begin
clrscr;
for i:=1 to 203 do
if i mod 2 = 1 then t:=t+i;
write(t);
end.
3).
program tongcacsochan;
uses crt;
var t,i:longint;
begin
clrscr;
for i:=1 to 20 do
if i mod 2 = 0 then t:=t+i;
write(t);
end.
Program HOC24;
Uses crt;
var i,j: integer;
j:=1; i:=0;
while(j<=50) do
begin
j:=j+1;
if(j mod 2=0) then i:=i+j;
end;
writeln(i);
readln;
end.
Uses Crt;
Var A : array [1..1000] of longint;
n, m, d, t, i, S, k : longint;
Begin
//Phan A
Clrscr;
Writeln(' Phan A ');
Write(' Ban hay nhap 1 so n bat ky: ');
Readln(n);
Write(' Cac so chia het cho ba tu 1 den ',n,' la: ');
For i:=1 to n do
If (i mod 3) = 0 then Write(' ',i);
//Phan B
Writeln;
Writeln(' Phan B ');
Write(' Ban hay nhap 1 so m bat ky: ');
Readln(m);
For i:=1 to m do
Begin
Write(' Ban hay nhap hang tu thu ',i,': ');
Readln(A[i]);
S:= S+A[i];
End;
Write(' Tong cua day so tren la: ',S);
//Phan C
Writeln;
Writeln(' Phan C ');
Write(' Ban hay nhap 1 so d bat ky: ');
Readln(d);
Write(' Ban hay nhap so K: ');
Readln(k);
For i:=1 to n do
Begin
Write(' Ban hay nhap hang tu thu ',i,': ');
Readln(A[i]);
If ((A[i] div k)=1)then t:=t+1;
End;
Write(' Co tat ca ',t,' so giong ',k);
Readln;
End.
T:=0;
for i:= 1 to 20 do
If i mod 2 = 1 then tong:=i + T;
begin
A:=0;
for i:=1 to 20 do A:= A+i*2;
writeln (' tong =',A);
readln;
end.
Program tinhtong;
var: i,s=longint;
Begin
i:=-1;
While i<50 do
Begin
i:=i+2;
S:-S+i;
End:
readln;
End.
Program HOC24;
var i,t: integer;
begin
i:=0; t:=0;
while i<=50 do
begin
i:=i+1;
t:=t+i;
end;
write('Tong cac so tu 1 den 50 la: ',T);
readln
end.