1. Viết chương trình in ra số lớn hơn trong 2 số được nhập từ bàn phím.
2. Viết chương trình in ra số lớn hơn trong 4 số được nhập từ bàn phím
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 ct; USES CRT; Var n,i: Integer; A:array[1..10] of 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]); Readln; End.
( Nếu đề chỉ yêu cầu là nhập 10 phần tử thì không cần khai báo n và thay n -> 10 trong câu lệnh for...do. Còn đề yêu cầu in n phần tử thì làm như trên).
Cách 1
program CTNMT;
uses crt;
var n,i: longint;
A: array [1..1000] of longint;
Begin
Writeln('Hay nhap vao so hoc sinh ban muon nhap diem: ');
Readln(N);
For i:=1 to n do
begin
Writeln('Nhap diem tin cua ban thu ',n);
Readln(A[i]);
end;
Readln;
end.
(Đây chỉ là chương trình nhập vào thôi nha, muốn xuất thì dùng cậu lệnh lặp để xuất từng phần tử của mảng)
Cách 2 bạn có thể thay thế bằng câu lệnh While...do cho câu For...to...do bằng câu lệnh: While i<=N do.........
tính UCLN của a và b
program uoc_chung;
uses crt;
var a,b: integer;
begin
writeln('nhap a='); readln(a);
writeln('nhap b='); readln(b);
while a>b do then a:=a-b
else b:=b-a;
if a=b then write ('uoc chung lon nhat la',a)
readln;
end.
BCNN tương tự
Program ucln_bcnn;
Uses crt;
Var x,y,uc,t,tamx,tamy:integer;
Begin
Clrscr;
Write('Nhap so nguyen duong x : '); readln(x);
Write('Nhap so nguyen duong y : '); readln(y);
tamx:=x;
tamy:=y;
t:=y mod x;
while t<>0 do
begin
t:=x mod y;
x:=y;
y:=t;
end;
uc:=x;
Writeln('- Ucln(' , tamx , ',' , tamy , ') la : ',uc );
Writeln('- Bcnn(' , tamx , ',' , tamy , ') la : ',(tamx*tamy) div uc );
Readln;
End.
var i,n,tb :integer;
begin
readln(n);
tb:=0;
for i:=1 to n do tb:=tb+1;
writeln(tb);
end.
program CTTTB;
uses crt;
var TB,x:real; n,y: integer;
begin
Write('Hay nhap so so thuc ban can tinh TB'); Readln(n);
for y:=1 to n do
begin Write('Nhap so thu',y);Readln(x);
TB:=TB+x;
end;
TB:=TB/n;
Writeln('Trung binh cong cua',n,' so nhap vao tu ban phim la',TB);
Readln;
End.
var i,n,s:integer;
begin
readln(n);
s:=0;
for i:=1 to n do s:=s+1/i;
writeln(s:3:0);
end.
2/ program bt;
var N,i:integer;
begin
write('nhap so N'); readln(N);
writeln;
writeln (' bang nhan ', N);
writeln;
for i:=1 to 10 do writeln(N,'x',1:2,'= ', N*1;3); end
readln
end.
Mik chỉ bít làm bài 2 thôi!
program loc_so_le;
uses crt;
var N,y: longint;
begin
Writeln('Nhap so N '); Readln(N);
for y:=1 to N do if (y mod 2) <>0 then Writeln (y,' la so le');
Readln;
end.
var i,n,s:integer;
A:array[1..100] ò longint;
begin
readln(n);
for i:=1 to n do
begin
write('A[',i,']=');
readln(A[i]);
end;
s:=0;
for i:=1 to n do s:=s+A[i];
write(s);
s:=0;
if A[i] mod 2=0 then s:=s+A[i];
write(s);
end.
bài 1
var i,n,S:longint;
begin
writeln('n=');
readln(n);
S:=0;
i:=0;
for i:=1 to n do
S:=S+n;
writeln('S=',S);
readln
end.
3
a) s:= 0 while X:=10 \(\rightarrow\) X<= 10
b) thiếu câu lệnh
c) n:=1
1.Program solonhon;
ues crt;
var a,b:real;
begin
clrscr;
write('nhap so a:');readln(a);
write('nhap so b:');readln(b);
if a>b then writeln('a lon hon');
if b> a then write('b lon hon')
else writeln('a=b');
readln
end.
2.program solonhon;
uses crt;
var a,b,c,d:real;
begin
clrscr;
write('nhap bon so a,b,c,d:'); readln(a,b,c,d);
if (a>b) and (a>c) and (a>d) then writeln('a lon hon')
else if (b>a) and (b>c) and (b>d) then writeln('b lon hon')
else if (c>a) and (c>b) and (c>d) then writeln('c lon hon')
else if (d>a) and (d>b) and (d>c) then writeln('d lon hon')
else write('a=b=c=d');
readln
end.