Viết chương tìm số lớn nhất trong 3 số a,b và 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.
uses crt;
var a,b,c,max,t:integer;
begin
clrscr;
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
max:=a;
if max<b then max:=b;
if max<c then max:=c;
t:=a+b+c;
writeln('Tong cua 3 so la: ',t);
writeln('So lon nhat trong 3 so la: ',max);
readln;
end.
program tim_chu_so;
uses crt;
var i,n,csln:longint;
k:integer;
a:array[1..1000]of longint;
st:string;
begin
clrscr;
write('nhap so n:');readln(n);
str(n,st);
val(st,a[i]);
csln:=a[1];
for i:=1 to length(st) do
if csln<a[i] then csln:=a[i];
writeln('chu so lon nhat cua so ',n,' la:',csln);
readln;
end.
Câu 1:
uses crt;
var n,i,d,x,y,max:integer;
st:string;
begin
clrscr;
write('Nhap n='); readln(n);
str(n,st);
d:=length(st);
max:=0;
for i:=1 to d do
begin
val(st[i],x,y);
if max<x then max:=x;
end;
writeln('Chu so lon nhat la: ',max);
readln;
end.
uses crt;
var a,b,c,nn:integer;
//chuongtrinhcon
function min(var x,y:integer):integer;
begin
if x<y then min:=x
else min:=y;
end;
//chuongtrinhchinh
begin
clrscr;
readln(a,b,c);
nn=min(a,b);
nn=min(nn,c);
writeln(nn);
readln;
end.
Đề 1:
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
Đề 2:
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
program Tim_so;
var
n, i, max, count: integer;
arr: array[1..100] of integer;
begin
writeln('Nhap vao so n: ');
readln(n);
writeln('Nhap vao day so: ');
for i := 1 to n do
begin
readln(arr[i]);
end;
max := arr[1];
count := 1;
for i := 2 to n do
begin
if(arr[i] > max) then
begin
max := arr[i];
count := 1;
end
else if(arr[i] = max) then
begin
count := count + 1;
end;
end;
writeln('So lon nhat la: ', max);
writeln('Co ', count, ' so lon nhat trong day.');
readln;
end.
a)
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln(max);
readln;
end.
b)
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
writeln(min);
readln;
end.
Program HOC24;
var a: array[1..32000] of integer;
i,max,min,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;
max:=a[1]; min:=a[1];
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('So nho nhat la :',max);
write('So lon nhat la: ',min);
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat la: ',max);
writeln('So nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
writeln('Gia tri lon nhat la: ',max);
dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then inc(dem);
writeln('So so chan la: ',dem);
readln;
end.
Tham khảo: