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 nhap_tinhtong;
uses crt;
type kmang=array[1..1000] of integer;
var A:kmang;
n:integer;
{---Nhap---}
procedure nhap;
var i:integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
end;
end;
{---Tinh-tong---}
function tinh_tong(A:kmang; n:integer):integer;
var t,i:integer;
begin
t:=0;
for i:=1 to n do
t:=t+A[i];
tinh_tong:=t;
end;
{---CT-chinh---}
BEGIN
clrscr;
nhap;
write('Tong cac phan tu la: ',tinh_tong(A,n));
readln;
end.
program nhap_tinhtong;
uses crt;
type kmang=array[1..1000] of integer;
var A:kmang;
n:integer;
{---Nhap---}
procedure nhap;
var i:integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('A[',i,']= '); readln(A[i]);
end;
end;
{---Tinh-tong---}
function tinh_tong(A:kmang; n:integer):integer;
var t,i:integer;
begin
t:=0;
for i:=1 to n do
t:=t+A[i];
tinh_tong:=t;
end;
{---CT-chinh---}
BEGIN
clrscr;
nhap;
write('Tong cac phan tu la: ',tinh_tong(A,n));
readln;
end.
Program HOC24;
var t: longint;
a,b: integer;
function gt(x: integer): longint;
var i: integer; tich: longint;
begin
tich:=1;
for i:=1 to n tich:=tich*i;
gt:=tich;
end;
begin
write('Nhap a: '); readln(a);
write('Nhap b: '); readln(b);
t:=gt(a)+gt(b)+gt(a-b);
write('T = ',t);
readln
end.
quá dễ
bài 1:
uses crt;
var a,b:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
if a=0 then
if b=0 then writeln('phuong trinh co vo so nghiem')
else writeln('phuong trinh vo nghiem')
else writeln('phuong trinh co nghiem x=',-b/a:4:2);
readln;
end.
bài 2:
uses crt;
var x,y,a,b,ucln:integer;
{---------------------------------------------------------}
procedure nhap(var n:integer);
begin
write('nhap mot so nguyen bat ky='); readln(n);
end;
{---------------------------------------------------------}
procedure rutgon(var a,b:integer);
var x,y,ucln:integer;
begin
x:=a;
y:=b;
while x<>y do
begin
if x>y then x:=x-y
else y:=y-x;
end;
ucln:=x;
if ucln<>1 then
begin
a:=a div ucln;
b:=b div ucln;
writeln('phan so toi gian la: ',a,'/',b);
end
else writeln('phan so toi gian la: ',a,'/',b);
end;
{----------------------------------------------------------}
begin
clrscr;
nhap(a);
nhap(b);
rutgon(a,b);
readln;
end.
Bài 1:
program pstg;
uses crt;
var a,b,i,u : integer;
f : text;
BEGIN
clrscr;
assign(f,'PSTG.INP');
reset(f);
read(f, a);
read(f, b);
u:=1;
for i:= 1 to a do if ((a mod i)=0) and ((b mod i)=0) and (i>u) then u:=i;
a:= a div u;
b:= b div u;
assign(f,'PSTG.OUT');
rewrite(f);
write(f, a,' ',b);
close(f);
END.
bài 4 dễ ẹt à
uses crt;
const fi='quediem.inp';
fo='quediem.out';
var i,m,n,d,x,j,csc:longint;
a,b:array[1..1000]of integer;
f1,f2:text;
begin
clrscr;
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
{-------------------------tim-so-lon-nhat--------------------------}
write(f2,'so lon nhat la: ');
m:=n;
if m mod 2=0 then
begin
for i:=1 to n div 2 do
write(f2,'1');
end
else begin
write(f2,'7');
for i:=2 to n div 2 do
write(f2,'1');
end;
{----------------------------tim-so-nho-nhat------------------------}
writeln(f2);
a[1]:=2; b[1]:=1;
a[2]:=5; b[2]:=2;
a[3]:=4; b[3]:=4;
a[4]:=6; b[4]:=6;
a[5]:=3; b[5]:=7;
a[6]:=7; b[6]:=8;
d:=(n div 7)+1;
if n mod 7=0 then d:=d-1;
if d=1 then begin
case n of
2:write(f2,'so nho nhat la: ',1);
3:write(f2,'so nho nhat la: ',7);
4:write(f2,'so nho nhat la: ',4);
5:write(f2,'so nho nhat la: ',2);
6:write(f2,'so nho nhat la: ',0);
7:write(f2,'so nho nhat la: ',8);
end;
end;
if d>1 then
begin
write(f2,'so nho nhat la: ');
for i:=1 to d do
if i=1 then begin
b[4]:=6;
for j:=1 to 6 do
begin
x:=n;
x:=x-a[j];
csc:=x div 7+1;
if x mod 7=0 then csc:=csc-1;
if csc=d-i then begin
write(f2,b[j]);
n:=x;
break;
end;
end;
end
else begin
a[1]:=6; b[1]:=0;
a[2]:=2; b[2]:=1;
a[3]:=5; b[3]:=2;
a[4]:=4; b[4]:=4;
a[5]:=3; b[5]:=7;
a[6]:=7; b[6]:=8;
for j:=1 to 6 do
begin
x:=n;
x:=x-a[j];
csc:=(x div 7)+1;
if x mod 7=0 then csc:=csc-1;
if csc=d-i then begin
write(f2,b[j]);
n:=x;
break;
end;
end;
end;
end;
close(f1);
close(f2);
readln;
end.
Mình viết chương trình chính thôi, bạn tự viết chương trình con nhé
uses crt;
var a:array[1..100]of integer;
i,n,t,tam,j:integer;
begin
clrscr;
write('Nhap n=');readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong diem cua ',n,' ban la: ',t);
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;
for i:=1 to n do
write(a[i]:4);
readln;
end.
Đáp án đúng : A