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:array[1..100]of integer;
n,i,t,kt,j,t1,t2,t3,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Day so ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so vua nhap la: ',t);
kt:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt:=1;
break;
end;
if (kt=0) and (t>1) then writeln(t,' la so nguyen to');
else writeln(t,' khong la so nguyen to');
t1:=0;
writeln('Cac so o vi tri le cua day la: ');
for i:=1 to n do
if i mod 2=1 then
begin
write(a[i]:4);
t1:=t1+a[i];
end;
writeln;
writeln('Tong cac so o vi tri le la: ',t1);
if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')
else writeln(t1,' khong la so chinh phuong');
t2:=0;
writeln('Cac so o vi tri chan la: ');
for i:=1 to n do
if i mod 2=0 then
begin
write(a[i]:4);
t2:=t2+a[i];
end;
writeln;
writeln('Tong cac so o vi tri chan la: ',t2);
t3:=0;
for i:=1 to t2 do
if t2 mod i=0 then t3:=t3+i;
if t3=t2 then writeln(t2,' la so hoan hao')
else writeln(t2,' khong la so hoan hao');
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('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
writeln('Tong cua hai so lon nhat va nho nhat la: ',max+min);
readln;
end.
uses crt;
var n,i,d,dem,kt,t,kt1,t1,t2,t3,max,min,x,j:integer;
a,b:array[1..100]of integer;
st:string;
begin
clrscr;
write('Nhap n='); readln(n);
str(n,st);
d:=length(st);
for i:=1 to d do
val(st[i],a[i],x);
dem:=1;
b[1]:=a[1];
for i:=1 to d do
begin
kt:=0;
for j:=1 to dem do
if a[i]=b[j] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
writeln('Cac chu so cua ',n,' la: ');
for i:=1 to dem do
write(b[i]:4);
writeln;
t:=0;
for i:=1 to d do
t:=t+a[i];
writeln('Tong cac chu so cua ',n,' la: ',t);
kt1:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt1:=1;
break;
end;
if (kt1=0) and (t>1) then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
writeln('Cac chu so o vi tri le cua ',n,' la: ');
t1:=0;
for i:=1 to d do
if i mod 2=1 then
begin
write(a[i]:4);
t1:=t1+a[i];
end;
writeln;
writeln('Tong cac chu so o vi tri le la: ',t1);
if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')
else writeln(t1,' khong la so chinh phuong');
writeln('Cac chu so o vi tri chan cua ',n,' la: ');
t2:=0;
for i:=1 to d do
if i mod 2=0 then
begin
write(a[i]:4);
t2:=t2+a[i];
end;
writeln('Tong cac chu so o vi tri chan la: ',t2);
t3:=0;
for i:=1 to t2 do
if t2 mod i=0 then t3:=t3+i;
if (t3=t2) and (t2>0) then writeln(t2,' la so hoan hao')
else writeln(t2,' khong la so hoan hao');
max:=a[1];
min:=a[1];
for i:=1 to d do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Chu so lon nhat cua ',n,' la: ',max);
writeln('Chu so nho nhat cua ',n,' la: ',min);
writeln('Tong cua chung la: ',max+min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,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 vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
kt:=0;
for j:=2 to trunc(sqrt(t)) do
if t mod j=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
readln;
end.
Cậu ơi sai khúc write('A[',i,']='); readln(a[i]); rồi nó cứ bị sao sao á
uses crt;
var a:array[1..100]of integer;
i,n,t,kt: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 ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cac so vua nhap la: ',t);
if t>=2 then
begin
kt:=0;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt:=1;
break;
end;
if kt=0 then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
end
else writeln(t,' khong la so nguyen to');
readln;
end.
Program HOC24;
var min,j,i,n,tg: integer;
t: longint;
a: array[1..1000] of integer;
begin
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ') else t:=t+a[i];
writeln; writeln('Tong cac so le la: ',t);
min:=a[1];
for i:=2 to n do if a[i]<min then min:=a[i];
writeln('So nhat nhat la: ',min);
for i:=1 to n do
for j:=i to n do
if a[i]>a[j] then
begin
tg:=a[i];
a[i]:=a[j];
a[j]:=tg;
end;
for i:=1 to n do write(a[i],' ');
readln
end.
Uses crt;
var i,n,min,k,e,j: longint
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(n); readln;
for i:=1 to n do if(a[i] mod 2=0) then write(a[i],' ');
for i:=1 to n do if(a[i] mod 2<>0) then k:=k+a[i];
min:=a[i];
for i:=1 to n do if(min>a[i]) then min:=a[i];
writeln(min);
for i:=1 to n-1 do
for j:=i+1 to n do if a[j] <=a[i] then
begin e:= a[i];
a[i]:=a[j];
a[j]:=e; end;
for i:=1 to n do write(a[i],';');
readln;
end.
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
i,n: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]:4);
readln;
end.
Uses crt;
var i,n,k,u,f,y: longint;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
writeln(a[i]);
for i:=1 to n do if(a[i]<0) then k:=k+a[i];
for i:=1 to n do if(a[i]>0) then u:=u+a[i];
for i:=1 to n do if(a[i] mod 2<>0) then f:=f+a[i];
for i:=1 to n do if(a[i] mod 2=0) then y:=y+a[i];
writeln('Tong cac so am la: ',k);
writeln('Tong cac so khong am: ',u);
writeln('Tong cac so le la: ',f);
writeln('Tong cac so chan la: ',y);
readln;
end.
program phiasaumocogai;
var
n, i, num, min, max, sum: integer;
average: real;
begin
write('Nhap so luong day so can kiem tra: ');
readln(n);
min := maxint;
max := -maxint;
sum := 0;
for i := 1 to n do
begin
write('Nhap day so thu ', i, ': ');
readln(num);
if num < min then
min := num;
if num > max then
max := num;
sum := sum + num;
end;
average := sum / n;
writeln('So nho nhat la: ', min);
writeln('So lon nhat la: ', max);
writeln('Tong cac day so la: ', sum);
writeln('Trung binh cua cac so la: ', average:0:2);
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2,t3,min,max:integer;
kt:boolean;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Day so ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
t:=t+a[i];
kt:=true;
for i:=2 to trunc(sqrt(t)) do
if t mod i=0 then
begin
kt:=false;
break;
end;
writeln('Tong cua day so la: ',t);
if (kt=true) and (t>1) then writeln(t,' la so nguyen to')
else writeln(t,' khong la so nguyen to');
writeln('Cac so o vi tri le cua day so la: ');
t1:=0;
for i:=1 to n do
if i mod 2=1 then
begin
write(a[i]:4);
t1:=t1+a[i];
end;
writeln;
writeln('Tong cac so o vi tri le cua day so la: ',t1);
if trunc(sqrt(t1))=sqrt(t1) then writeln(t1,' la so chinh phuong')
else writeln(t1,' khong la so chinh phuong');
writeln('Cac so o vi tri chan cua day so la: ');
t2:=0;
for i:=1 to n do
if i mod 2=0 then
begin
write(a[i]:4);
t2:=t2+a[i];
end;
writeln;
writeln('Tong cac so o vi tri chan cua day so la: ',t2);
t3:=0;
for i:=1 to t2 do
if t2 mod i=0 then t3:=t3+i;
if t3=t2 then writeln(t2,' la so hoan hao')
else writeln(t2,' khong la so hoan hao');
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 cua day la: ',max);
writeln('So nho nhat cua day la: ',min);
writeln('Tong cua so lon nhat va so nho nhat la: ',max+min);
readln;
end.