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.
Bài 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
if a[i] mod 2<>0 then write(a[i]:4);
readln;
end.
Bài 2:
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
if a[i] mod 2=0 then write(a[i]:4);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('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.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('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 HOC24;
var a: array[1..1000] of integer;
i,k,min: integer;
begin
write('Nhap K: '); readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
min:=a[1];
for i:=2 to k do if a[i]<min then min:=a[i];
write('Phan tu nho nhat trong day so la: ',min);
readln
end.
Uses crt;
var i,k,min: longint;
h: array[1..100] of longint;
begin clrscr;
readln(k);
for i:=1 to k do begin
readln(h[i]);
end;
min:=h[1];
for i:=1 to n do begin
if(min>h[i]) then min:=h[i];
end;
writeln(min);
readln;
end.
Uses crt;
var max,min,n,i,m,n: longint;
a: array[1..100] of longint
begin clrscr;
for i:=1 to n do begin
if(a[i] mod 2=0) then m:=m+a[i];
if(a[i] mod 2<>0) then n:=n+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('Tong cac phan tu chan: ',m);
Writeln('Tong cac phan tu le: ',n);
Writeln('Phan tu co gia tri lon nhat: ',max);
Writeln('Phan tu co gia tri nho nhat: ',min);
readln;
end.
a) var a:array[1..1000] of integer;
i,k:integer;
p:longint;
begin
write('k = ');readln(k);
p:=1;
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<30 then p:=p*a[i];
end;
write('Tich la ',p);
readln
end.
b)
var a:array[1..1000] of integer;
i,k:integer;
s:longint;
begin
write('k = ');readln(k);
for i:=1 to k do
begin
write('Nhap so thu ',i,' = ');readln(a[i]);
if a[i]<100 then s:=s+a[i];
end;
write('Tong la ',s);
readln
end.
Uses crt;
var n,i,max,min: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); readln;
max:=a[1];
for i:=1 to n do if(max<a[i]) then max:=a[i];
writeln(max);
min:=a[1];
for i:=1 to n do if(min>a[i]) then min:=a[i];
writeln(min);
readln;
end.
Câu 1:
uses crt;
var a:array[1..200]of integer;
i,n,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln(t);
readln;
end.
c:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
d:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,nn;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=1; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,x;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
sort(a+1,a+n+1);
for (i=1; i<=n; i++)
{
int x=sqrt(a[i]);
if (x*x==a[i])
{
cout<<x;
return 0;
}
}
cout<<"Ko co so chinh phuong trong day";
return 0;
}
uses crt;
var x,i,max,n,dem,dem1,dem2,dem3,t,t1:integer;
a,b,c,d,e:array[-32000..32000]of integer;
tbca,tbcd:real;
begin
clrscr;
write(‘n=’); readln(n);
for i:=1 to n do
begin
write(‘a[‘,i,’]=’); readln(a[i]);
inc(b[a[i]]);
end;
{———————————-cau-a—————————-}
max:=0;
for i:=1 to n do
if max<b[a[i]] then
begin
max:=b[a[i]];
x:=a[i];
end;
writeln(‘phan tu co so lan xuat hien nhieu nhat trong mang la: ‘,x);
{——————————–cau-b——————————-}
dem:=0;
for i:=1 to n do
if a[i]>=0 then
begin
dem:=dem+1;
c[dem]:=a[i];
end;
dem1:=0;
for i:=1 to dem do
if trunc(sqrt(c[i]))=sqrt(c[i]) then inc(dem1);
writeln(‘so luong so chinh phuong trong day la: ‘,dem1);
{——————————–cau-c—————————–}
dem2:=0;
dem3:=0;
for i:=1 to n do
begin
if a[i]>0 then
begin
inc(dem2);
d[dem2]:=a[i];
end;
if a[i]<0 then
begin
inc(dem3);
e[dem3]:=a[i];
end;
end;
t:=0;
t1:=0;
for i:=1 to dem2 do
t:=t+d[i];
tbcd:=t/dem2;
for i:=1 to dem3 do
t1:=t1+e[i];
tbca:=t1/dem3;
writeln(‘trung binh cong cac so am la: ‘,tbca:4:2);
writeln(‘trung binh cong cac so duong la: ‘,tbcd:4:2);
readln;
end.