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.
Lời giải :
program hotrotinhoc ;
var a: array[1..32000] of integer ;
i,n,max : integer ;
begin
write('Nhap n='); readln(n);
writeln('Nhap gia tri cua cac phan tu');
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];
write('So lon nhat la:',max');
readln
end.
program so_tu_nhien_chan;
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
write('Cac so chan nho hon hoac bang ',n,' la: ');
for i:=2 to n do
if i mod 2=0 then write(i:4,' ;');
readln;
end.
uses crt;
var n,i,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
t:=0;
for i:=1 to n do
if i mod 3=0 then t:=t+i;
writeln(t);
readln;
end.
Câu 2:
Program HOC24;
var a: array[1..20] of integer;
t,i: integer;
begin
for i:=1 to 20 do
begin
write('Nhap so thu ',i,' : '); readln(a[i]);
end;
t:=0;
for i:=1 to 20 do
if a[i] mod 2<>0 then t:=t+a[i];
writeln('Tong cac so le la :',t);
readln
end.
Câu 1:
Program HOC24;
var a: array[1..10] of integer;
min,max,i: integer;
begin
for i:=1 to 10 do
begin
write('Nhap so thu ',i,' : '); readln(a[i]);
end;
min:=32000; max:=0;
for i:=1 to 10 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);
write('So nho nhat la : ',min);
readln
end.
uses crt;
var X:string;
demtu,demdc,i:word;
begin
clrscr;
write('nhap cau van X:');readln(X);
writeln('so ki tu la:',length(X));
demtu:=1;
for i:=1 to length(X)-1 do
if (X[i]<>' ') and (X[i+1]=' ') then demtu:=demtu+1;
writeln('so tu la:',demtu);
demdc:=0;
for i:=1 to length(X) do
if X[i]=' ' then demdc:=demdc+1;
writeln('so dau cach la:',demdc);
readln;
end.
bài này mới đúng nè bạn:
uses crt;
var X:string;
demtu,demdc,i:word;
begin
clrscr;
write('nhap cau van X:');readln(X);
writeln('so ki tu la:',length(X));
X:=X+' ';
demtu:=0;
for i:=1 to length(X)-1 do
if (X[i]<>' ') and (X[i+1]=' ') then demtu:=demtu+1;
writeln('so tu la:',demtu);
delete(X,length(X),1);
demdc:=0;
for i:=1 to length(X) do
if X[i]=' ' then demdc:=demdc+1;
writeln('so dau cach la:',demdc);
readln;
end.
uses crt;
var a:array[1..100]of integer;
n,i,kt,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so nguyen duong la: ');
for i:=1 to n do
if a[i]>0 then write(a[i]:4);
writeln;
writeln('Cac so nguyen to la: ');
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to a[i]-1 do
if a[i] mod j=0 then kt:=1;
if kt=0 then write(a[i]:4);
end;
readln;
end.