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 TongLe;
var
N, i, Tong: integer;
A: array[1..50] of integer;
begin
write('Nhap so phan tu cua mang N (N <= 50): ');
readln(N);
for i := 1 to N do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
Tong := 0;
for i := 1 to N do
begin
if(A[i] mod 2 <> 0) then
begin
Tong := Tong + A[i];
end;
end;
writeln('Tong cac so le trong mang A la: ', Tong);
readln;
end.
Program ct;
Var i,n,so le, so chan:integer;
B:Array[1..n] of integer;
Begin
Write('n=');Readln(n);
For i:=1 to n do begin Write('B[',i,']=');
Readln(B[i]);
End;
For i:=1 to n do Begin
if B[i] mod 2 <>0 then writeln('so le , ' );
If B[i] mod 2=0 then writeln('so chan ,' );
End;
Readln
End.
Lời giải:
Bài 1 :
a) var A : array[1..100] of real ;
b) var B : array[1..20] of integer ;
c) A[7] := 8 ;
Bài 2 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
readln
end.
Bài 3 :
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('Co tat ca so ban hoc sinh la'); readln(n);
write('Nhap diem mon tin cua cac ban');
for i:= 1 to n do
begin
write('Ban thu ',i,':'); readln(a[i]);
end;
readln
end.
Bài 4 : a,b giống bài 3
c)
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n,tong : integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
tong:=0;
for i:= 1 to n do
if a[i] > 0 then tong:=tong+1;
write('Ket qua la',tong);
readln
end.
Bài 5: a và b tương tự bài 3
c+d )
program hotrinhoc ;
var a: array[1..32000] of integer ;
i,n: integer ;
begin
write('nhap do dai cua mang'); readln(n);
write('Nhap cac gia tri cua phan tu');
for i:= 1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
for i:= 1 to n do
c) if i mod 2= 0 then write('Cac so chan cua mang la:',i);
d) if i mod 2= 1 then write('Cac so le cua mang la:',i);
readln
end.
uses crt;
var a:array[1..1000000] of longint;
n,i,d:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
if a[i] mod 2=1 then inc(d);
end;
write('Co ',d,' gia tri la so le');
readln;
end.
Làm như z có đg ko
Uses crt;
Var n,i: integer;
A: Array[1..1000] of integer;
Begin
clrscr;
Repeat
Write('Nhap n: '); Readln(n);
Until (n<103) and (n>0);
a)
For i:=1 to n do
begin
Write('Nhap phan tu A[',i,']= ');
Readln(A[i]);
end;
b)
Write('Cac phan tu chan co trong mang: ');
For i:=1 to n do
If A[i] mod 2=0 then write(A[i],' ');
writeln;
c)
Write('Cac phan tu le co trong mang: ');
For i:=1 to n do
If A[i] mod 2=1 then write(A[i],' ');
Readln
End.
Uses crt;
var i,n: longint;
a: array[1..103] of longint;
begin clrscr;
readln(n);
for i:=1 to n do read(a[i]); 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 write(a[i],' ');
readln;
end.
uses crt;
var a:array[1..1000000] of longint;
n,i,s:longint;
begin
clrscr;
write('Nhap so luong phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
if a[i] mod 2=1 then inc(s,a[i]);
end;
write('Tong cac so le: ',s);
readln;
end.
Program HOC24;
var d,i,n: integer;
a: array[1..1000] of integer;
begin
write('Nhap do dai cua day: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
d:=0;
for i:=1 to n do if a[i] mod 2=1 then d:=d+1;
write('Co tat ca ',d,' gia tri le');
readln
end.
Var a:array:[1..1000] of integer;
i,n,max:integer;
Begin
Write('Nhap so luong phan tu n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap diem thu ',i,' = ');readln(a[i]);
End;
Write('Cac diem vua nhap la: ');
For i:=1 to n do
Write(a[i]:8);
writeln;
max:=a[1];
For i:=2 to n do
if a[i] > max then max:=a[i];
write('So lon nhat la ',max);
Readln
End.
Var a:array:[1..50] of integer;
i:integer;
s:longint;
Begin
For i:=1 to 50 do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
If a[i] mod 2 <> 0 then
s:=s+a[i];
End;
Write('Tong cac so le la: ',s);
Readln
End.