0% found this document useful (0 votes)
6 views3 pages

Program Yeucau

tin hoc

Uploaded by

2357060012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Program Yeucau

tin hoc

Uploaded by

2357060012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

program Yeucau;

uses crt;
var a:array [1..100] of integer;
n,i:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
write('Mang A: ');
for i:=1 to n do write(a[i]:5);
readln;
end.

{program Bai1;
uses crt;
var a:array [1..100] of integer;
n,k,i,tong,dem:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
write('Nhap k: '); readln(k);
tong:=0; dem:=0;
for i:=1 to n do
if a[i] mod k=0 then
begin
dem:=dem+1;
tong:=tong+a[i];
end;
writeln('Co ',dem,' boi cua k. Tong = ',tong);
readln;
end.}

{program Bai2;
uses crt;
var a:array [1..100] of integer;
n,i,tong,dem:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
tong:=0; dem:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
dem:=dem+1;
tong:=tong+a[i];
end;
writeln('Co ',dem,' so chan. Tong = ',tong);
tong:=0; dem:=0;
for i:=1 to n do
if a[i] mod 2=1 then
begin
dem:=dem+1;
tong:=tong+a[i];
end;
writeln('Co ',dem,' so le. Tong = ',tong);
tong:=0; dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
dem:=dem+1;
tong:=tong+a[i];
end;
writeln('Co ',dem,' so chia het cho 3. Tong = ',tong);
readln;
end.}

{program Bai3;
uses crt;
var a:array [1..100] of integer;
n,i,dem,k:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
write('Nhap k: '); readln(k);
dem:=0;
for i:=1 to n do
if a[i]=k then dem:=dem+1;
if dem=0 then writeln('So ',k,' khong xuat hien trong A')
else writeln('So lan xuat hien = ',dem);
readln;
end.}

{program Bai4;
uses crt;
var a:array [1..100] of integer;
n,i,min,max,chiso:integer;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': ');
readln(a[i]);
end;
max:=-10000;
for i:=1 to n do
if a[i]>max then
begin
max:=a[i];
chiso:=i;
end;
writeln('Phan tu lon nhat trong mang A co chi so: ',chiso);
min:=10000;
for i:=1 to n do
if a[i]<min then
begin
min:=a[i];
chiso:=i;
end;
writeln('Phan tu nho nhat trong mang A co chi so: ',chiso);
readln;
end.}

You might also like