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.
Program HOC24;
var d,i,n: integer;
a: array[1..32000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
write('Cac phan tu cua mang vua nhap la: ');
for i:=1 to n do write(a[i],' ');
writeln;
d:=0;
for i:=1 to n do if 10 mod a[i]=0 then d:=d+1;
writeln('Co ',d,' phan tu co gia tri la uoc cua 10');
write('Cac phan tu o vi tri chan la: ');
for i:=1 to n do if i mod 2=0 then write(a[i],' ');
writeln;
write('Cac phan tu o vi tri le la: ');
for i:=1 to n do if i mod 2=1 then write(a[i],' ');
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,max,t,min,dem1:integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
max:=-32000;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem:=dem+1;
if max<a[i] then max:=a[i];
end;
if dem=0 then writeln('Trong day khong co so chan')
else begin
writeln('So so chan la: ',dem);
writeln('So chan lon nhat la: ',max);
end;
t:=0;
for i:=1 to n do
if i mod 2=1 then t:=t+a[i];
writeln('Tong cac so o vi tri le la: ',t);
min:=maxint;
dem1:=0;
for i:=1 to n do
if a[i] mod 2<>0 then
begin
inc(dem1);
if min>a[i] then min:=a[i];
end;
if dem1=0 then writeln('Trong day khong co so le')
else writeln('So le nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
begin
readln(a[i]);
end;
for i:=1 to n do
write(a[i]:4);
readln;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 10=0 then
begin
write(a[i]:4);
inc(dem);
t:=t+a[i];
end;
writeln;
writeln(dem);
writeln(t);
readln;
end.
program chuongtrinh;
uses crt;
var chan, le, i,dem1, dem2 :integer;
a:array [1 .. 1000 ] of integer;
begin
write (' Nhap gia tri n = ');
readln (n);
for i:=1 to n do
begin
write ('a[',i,']= ');
readln (a[i]);
end;
chan:= 0;
dem1:=0;
dem2:=0;
le:= 0;
for i:=1 to n do if i mod 2 = 0 then
begin
dem1:=dem1+1;
chan:=chan+a[i];
end;
for i:=1 to n do if i mod 2 <> 0 then
begin
dem2:=dem2+1;
le:=le+a[i];
end;
writeln (' Tong chan la: ',chan);
writeln (' So phan tu chan trong mang la: ',dem1);
writeln (' Tong le la: ',le);
writeln (' So phan tu le trong mang la: ', dem2);
readln
end.
P/S: thử xem được không nhé.
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.
program dem;
var
n, i, chan, le: integer;
a: array[1..1000] of integer;
begin
write('Nhap so phan tu cua day: ');
readln(n);
for i := 1 to n do
begin
write('Nhap phan tu thu ', i, ': ');
readln(a[i]);
end;
chan := 0;
le := 0;
for i := 1 to n do
begin
if (a[i] mod 2 = 0) then
chan := chan + 1
else
le := le + 1;
end;
writeln('So phan tu chan trong day la: ', chan);
writeln('So phan tu le trong day la: ', le);
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x>0) dem++;
}
cout<<dem;
return 0;
}
Var a:array[1..20] of integer;
i,n,d:integer;
Begin
For i:=1 to 20 do
Begin
Write('Nhap phan tu thu ',i);readln(a[i]);
if a[i] = 3 then d:=d+1;
End;
Write('Co ',d,' chu so 3');
Readln
End.
program DemSoChanLeTrongMang;
var
A: array of Integer;
n, i, demChan, demLe: Integer;
begin
Write('Nhap so phan tu cua mang: ');
Readln(n);
SetLength(A, n);
for i:= 0 to n-1 do
begin
Write('A[', i, ']= ');
Readln(A[i]);
end;
demChan := 0;
demLe := 0;
for i:= 0 to n-1 do
begin
if A[i] mod 2 = 0 then
demChan := demChan + 1
else
demLe := demLe + 1;
end;
Writeln('So luong so chan trong mang la: ', demChan);
Writeln('So luong so le trong mang la: ', demLe);
end.