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.
uses crt;
var a:array[1..50]of integer;
i,n,t: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 do
write(a[i]:4);
t:=0;
for i:=1 to n do
if (a[i] mod 2<>0) and (a[i] mod 5=0) then t:=t+a[i];
writeln;
writeln(t);
readln;
end.
uses crt;
var x,y:integer;
begin
clrscr;
write('Nhap x='); readln(x);
write('Nhap y='); readln(y);
if x>y then writeln(x-y)
else writeln(x+y);
readln;
end.
uses crt;
var x,y:integer;
begin
clrscr;
write('Nhap x='); readln(x);
write('Nhap y='); readln(y);
if x>y then writeln(x-y)
else writeln(x+y);
readln;
end.
uses crt;
var a:array[1..200]of integer;
n,i,k,t,t1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod 2<>0 then t:=t+a[i];
t1:=0;
for i:=1 to n do
if a[i] mod k=0 then t1:=t1+a[i];
writeln('Tong cac phan tu le la: ',t);
writeln('Tong cac phan tu la boi cua ',k,' la: ',t1);
readln;
end.
1:
uses crt;
var a,b,i,tsc,tsl:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if (a>0) and (b>0) then
begin
if a<b then
begin
tsc:=0;
tsl:=0;
for i:=a to b do
if i mod 2=0 then tsc:=tsc+i
else tsl:=tsl+i;
writeln('tong cac so chan trong khoang tu ',a,' toi ',b,' la: ',tsc);
writeln('tong cac so le trong khoang tu ',a,' toi ',b,' la: ',tsl);
end
else writeln('vui long nhap a be hon b');
end
else writeln('vui long nhap hai so duong');
readln;
end.
2:
uses crt;
var n,i:integer;
begin
clrscr;
write('n='); readln(n);
if (n>=5) then
begin
writeln('cac so nguyen le trong khoang tu 5 toi ',n,' la: ');
for i:=5 to n do
if i mod 2=1 then write(i:4);
end
else writeln('vui long nhap n lon hon hoac bang 5');
readln;
end.
3:
uses crt;
var m,n,i:integer;
s:longint;
begin
clrscr;
write('m='); readln(m);
write('n='); readln(n);
if (m>0) and (n>0) then
begin
if m<n then
begin
s:=1;
for i:=m to n do
if i mod 2=0 then s:=s*i;
writeln('tich cac so chan trong pham vi tu ',m,' toi ',n,' la: ',s);
end
else writeln('vui long nhap m nho hon n');
end
else writeln('vui long nhap hai so duong');
readln;
end.
4:
uses crt;
var x,y,i,j:integer;
begin
clrscr;
write('x='); readln(x);
write('y='); readln(y);
if (x>0) and (y>0) then
begin
if x<y then
begin
writeln('day cac so nguyen duong trong pham vi tu ',x,' toi ',y,' la:');
for i:=x to y do
write(i:4);
writeln;
writeln('day cac so nguyen duong trong pham vi tu ',y,' toi ',x,' la:');
for j:=y downto x do
write(j:4);
end
else writeln('vui long nhap x nho hon y');
end
else writeln('vui long nhap hai so duong');
readln;
end.
uses crt;
var x,y:integer;
begin
clrscr;
write('Nhap x='); readln(x);
write('Nhap y='); readln(y);
writeln(x+y);
readln;
end.
Bài 2:
uses crt;
var n,i,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do
if (i mod 3=0) and (i mod 5=0) then t:=t+i;
writeln(t);
readln;
end.
Bài 1
uses crt;
var i,t:integer;
begin
clrscr;
t:=0;
for i:=1 to 50 do
t:=t+i;
writeln('tong cua cac so nguyen trong pham vi tu 1 toi 50 la: ',t);
writeln('cac so chia het cho 5 trong khoang tu 1 toi 50 la: ');
for i:=1 to 50 do
if i mod 5=0 then write(i:4);
writeln;
writeln('cac so le trong khoang tu 1 toi 50 la: ');
for i:=1 to 50 do
if i mod 2=1 then write(i:4);
bài 2: Viết phương trình tính y= x^2 + y^2 nếu x>y và xy+y^2x nếu x^2+y^2>xy
uses crt;
var x,y,t,hieu:integer;
begin
clrscr;
write('x='); readln(x);
write('y='); readln(y);
if x>y then
begin
t:=sqr(x)+sqr(y);
writeln(t);
end;
if sqr(x)+sqr(y)>x*y then
begin
hieu:=x*y+sqr(y)*x;
writeln(hieu);
end;
readln;
end.