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 hotrotinhoc;
const fi='lientiep.inp';
fo='lientiep.out';
var f: text;
a,b: array[1..32000] of integer;
k,i,n,max,vtd,vtc: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
readln(f,n,k);
for i:=1 to n do read(f,a[i]);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
max:=0; i:=1;
while i<=n do
begin
j:=i;
t:=a[i];
while (a[j]<a[j+1]) and (j<=n) do
begin
inc(j);
t:=t+a[j];
end;
if t>max then
begin
max:=t;
vtd:=i;
vtc:=j;
end;
i:=j+1;
end;
for i:=vtc downto vtd do
begin
inc(d1);
b[d1]:=a[i];
end;
for i:= k dowto 1 do
write(f,b[i],' ');
close(f);
end;
begin
ip;
out;
end.
Program Vidu;
Uses crt;
Type Mang1C = array[1..10] of Integer; {khai báo tên mảng – cách 2}
Var A:Mang1C; {Đặt tên mảng là A}
i:integer;
Begin
clrscr;
Writeln('Nhap gia tri cho mang A');
For i:=1 to 10 do
Begin
Write('A[',i,'] = ');
Readln(A[i]); { đọc vào giá trị cho A thứ i}
End;
Write('Danh sach cac phan tu trong mang A: ');
For i:=1 to 10 do
Write(A[i]:5);
Readln;
End.
Bài 2:
Program HOC24;
var a: array[1..200] of integer;
i,d,n: integer;
begin
write('Nhap so phan tu N: '); readln(N);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:=1 to n do if a[i] mod 3=0 then d:=d+1;
write('Co ',d,' phan tu chia het cho 3');
readln
end.
Bài 3:
Program HOC24;
var a: array[1..30] of integer;
i,d,n: integer;
begin
write('Nhap so phan tu N: '); readln(N);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
d:=1;
for i:=1 to n do if a[i] mod 2=0 then d:=d*a[i];
write(Tich cac phan tu chia het cho 2 la: ',d);
readln
end.
tổ ong
var S,N:int64;
f:text;
Begin
assign(f,'BEEHIVE.INP');
reset(f);
readln(f,N);
close(f);
if N=1 then S:=1
else S:=1+6*((N-1)*N div 2);
assign(f,'BEEHIVE.OUT');
rewrite(f);
writeln(f,S);
close(f);
end.
ốc sên
uses crt;
const
fi='SNAIL.INP';
fo='SNAIL.OUT';
Var a,b,v,x:longint;
f:text;
Begin
clrscr;
assign(f,fi);reset(f);
readln(f,a,b,v);
close(f);
x:=(V-a)div(a-b)+1;
if (V-a)mod(a-b)<>0 then inc(x);
assign(f,fo);rewrite(f);
writeln(f,x);
close(f);
end.
trên là 1 cách giải xin mọi người cho cách khác
Câu 1:
uses crt;
var a:array[1..100]of integer;
n,i,tl,tc:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
tc:=0;
tl:=0;
for i:=1 to n do
begin
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 so nguyen chan cua day la: ',tc);
writeln('tong so nguyen le cua day la: ',tl);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
n,i:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly-----------------------------}
writeln('cac so nguyen am co trong day la: ');
for i:=1 to n do
if a[i]<0 then write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly-----------------------------}
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('tong cac phan tu chia het cho 3 la: ',t);
readln;
end.
Câu 4:
uses crt;
var a,vt:array[1..100]of integer;
n,i,t,dem,j:integer;
min:int64;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
min:=maxint;
for i:=1 to n do
if min>a[i] then min:=a[i];
dem:=0;
for i:=1 to n do
if a[i]=min then
begin
inc(dem);
vt[dem]:=i;
end;
writeln('so nho nhat la: ',min);
writeln('vi tri cua no trong day lan luot la: ');
for j:=1 to dem do
write(vt[j]:4);
readln;
end.
Câu 5:
uses crt;
var a,vt:array[1..100]of integer;
n,i,j,tam:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
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 so giam dan la: ');
for i:=1 to n do
write(a[i]:4);
readln;
end.
Program hotrotinhoc;
var a,b,i: word;
function nt(x: word) : boolean;
var j: integer;
begin
nt:=true;
if (x=2) or (x=3) then exit;
nt:=false;
if (x=1) or (x mod 2=0) or (x mod 3=0) then exit;
j:=6;
while j<=trunc(sqrt(x)) do
begin
if (x mod j=0) or (x mod (j+2)=0) then exit;
i:=i+5;
end;
nt:=true;
end;
begin
readln(a,b);
for i:=a to b do if nt(i) then writeln(i);
readln
end.
uses crt;
var a,b,kt,i,j:integer;
begin
clrscr;
write('nhap a='); readln(a);
write('nhap b='); readln(b);
if a<b then
begin
for i:=a to b do
begin
kt:=0;
for j:=2 to i-1 do
if i mod j=0 then kt:=1;
if kt=0 then writeln(i);
end;
end;
readln;
end.
uses crt;
var n,a,b,q:integer;
begin
clrscr;
write('n='); readln(n);
for a:=1 to n do
for b:=a to n do
if trunc(sqrt(sqr(a)+sqr(b)))=sqrt(sqr(a)+sqr(b)) then writeln(a,' ',b);
readln;
end.