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 HOC24;
var a: array[1..100] of integer;
i,n,d: integer;
t: longint;
begin
write('Nhap so phan tu n='); readln(n);
d:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i]>0 then
begin
d:=d+1;
t:=t+a[i];
end;
end;
write('Trung binh cong cac so duong trong mang la :',t/d:1:2);
readln
end.
uses crt; var A:array[1..100] of integer; Procedure Nhap(var T:array of integer); var i:integer; begin for i:= 1 to 50 do begin write('Nhap so thu ',i,' :'); readln(T[i]); end; end; function tbc(T: array of integer):real; var j,S,d:integer; begin S:=0; d:=0; for j:=1 to 50 do if T[j] mod 5 =0 then begin S:=S+T[j]; d:=d+1; end; tbc:=S/d end; begin clrscr; Nhap(A); write('TBC :',tbc(A)); readln 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.
Lời giải:
program hotrotinhoc;
var a,b : integer;
s: longint;
t: real;
begin
write('A='); readln(a);
write('B='); readln(b);
s:=a;
s:=s+b;
writeln(s);
s:=0;
s:=a;
s:=s-b;
writeln(s);
s:=0;
s:=a;
s:=s*b;
writeln(s);
t:=a;
t:=t/b;
write(t:1:2);
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.