Vct xuất ra các số âm gần 0 nhất
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.
Bài 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n,d: integer;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;
write('Co ',d,' so nguyen am chan trong day so');
readln
end.
Bài 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer;
t: longint;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i];
write(Tong la: ',t);
readln
end.
1.
Program HOC24;
var a: array[1..32000] of longint;
i,n: integer;
tc,tl: longint;
begin
write('Nhap N: '); readln(n);
tc:=0; tl:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] mod 2=0 then tc:=tc+a[i];
if a[i] mod 2=1 then tl:=tl+a[i];
end;
writeln('Tong chan la: ',tc);
write('Tong le la: ',tl);
readln
end.
2.
Program HOC24;
var a: array[1..32000] of longint;
d1,d2,i,n: integer;
begin
write('Nhap N: '); readln(n);
d1:=0; d2:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] >0 then d1:=d1+1;
if a[i] <0 then d2:=d2+1;
end;
writeln('Co ',d1,' so lon hon 0');
write('Co ',d2,' so be hon 0');
readln
end.
var tam,a,b,i:integer;
begin
write('a = ');readln(a);
write('b = ');readln(b);
if a < b then
begin
tam:=a;
a:=b;
b:=tam;
end;
for i:=a to b do
if sqrt(i) = trunc(sqrt(i)) then write(i:10);
readln;
End.
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n: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);
readln;
end.
program TinhTongVaUoc;
var
a, b, sum, i: integer;
uoc: boolean;
begin
write('Nhap so a: ');
readln(a);
write('Nhap so b: ');
readln(b);
// Tinh tong a+b
sum := a + b;
writeln('Tong cua a va b la: ', sum);
// In ra cac uoc cua tong
write('Cac uoc cua tong a+b la: ');
for i := 1 to sum do
begin
if sum mod i = 0 then
write(i, ' ');
end;
writeln;
// Kiem tra xem tong a+b co phai la so hoan hao hay khong
uoc := false;
for i := 1 to sum - 1 do
begin
if sum mod i = 0 then
uoc := true;
end;
if uoc and (sum = 2 * sum div 2) then
writeln('Tong a+b la so hoan hao')
else
writeln('Tong a+b khong phai la so hoan hao');
end.
program TinhTongVaUocSo;
var
a, b, tong, i: integer;
laSoNguyenTo: boolean;
begin
write('Nhap a: ');
readln(a);
write('Nhap b: ');
readln(b);
tong := a + b;
writeln('Tong cua a va b la: ', tong);
writeln('Uoc so cua tong la:');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
laSoNguyenTo := true;
if tong < 2 then
laSoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
if tong mod i = 0 then
begin
laSoNguyenTo := false;
break;
end;
if laSoNguyenTo then
writeln('Tong a va b la so nguyen to')
else
writeln('Tong a va b khong phai la so nguyen to');
readln;
end.
program TinhTongVaUocCuaTong;
var a, b, tong, i: integer;
SoNguyenTo: boolean;
begin
writeln('Nhap vao hai so a va b (a > 0, b > 0): ');
write('a = ');
readln(a);
write('b = ');
readln(b);
tong := a + b;
writeln('Tong cua a + b = ', tong);
writeln('Uoc cua tong a + b: ');
for i := 1 to tong do
begin
if tong mod i = 0 then
writeln(i);
end;
SoNguyenTo := true;
if tong < 2 then
SoNguyenTo := false
else
for i := 2 to trunc(sqrt(tong)) do
begin
if tong mod i = 0 then
begin
SoNguyenTo := false;
break;
end;
end;
if SoNguyenTo then
writeln('Tong a + b la so nguyen to:')
else
writeln('Tong a + b khong phai la so nguyen to:');
end.
ý bạn là n số âm gần 0 nhất hay sao
nếu là 1 số thì
uses crt;
begin
clrscr;
write(-1);
readln;
end.