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.
program BaiTap;
var
A: array[1..150] of integer;
N, i, sum: integer;
begin
write('Nhap so phan tu cua day A (N <= 150): ');
readln(N);
for i := 1 to N do
begin
write('Nhap phan tu thu ', i, ': ');
readln(A[i]);
end;
writeln('Day so vua nhap la:');
for i := 1 to N do
write(A[i], ' ');
writeln;
sum := 0;
for i := 1 to N do
if A[i] mod 2 = 0 then
sum := sum + A[i];
writeln('Tong cac phan tu chan trong day la: ', sum);
readln;
end.
1:
#include <bits/stdc++.h>
using namespace std;
long long n=10, a[10],i,nn;
int main()
{
for (i=1; i<=n; i++) cin>>a[i];
nn=a[1];
for (i=2; i<=n; i++) nn=min(nn,a[i]);
cout<<nn;
return 0;
}
program HienThiSoChan;
var
N, i: integer;
A: array[1..50] of integer;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
writeln('Nhap day so A gom ', N, ' phan tu:');
for i := 1 to N do
begin
readln(A[i]);
if A[i] mod 2 = 0 then
begin
writeln('Phan tu thu ', i, ' la so chan: ', A[i]);
end;
end;
readln;
end.
program TongChanLe;
var
n,i, chans, les: integer; a: array[1..100] of integer;
begin
chans := 0;
les := 0;
write('Nhap n: ');
readln(n);
for i:=1 to n do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
if a[i] mod 2 = 0 then
chans := chans + a[i]
else
les := les + a[i];
end;
writeln('Tong cac so chan la: ', chans);
writeln('Tong cac so le la: ', les);
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.
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.
Var a:array[1..1000] of integer;
i,n:integer;
sc,sl:longint;
Begin
Write('Nhap so luong so cua day ');readln(n);
For i:=1 to n do
Begin
Write(a,'[',i,'] = ');readln(a[i]);
End;
Write('Tong cac so chan la ');
For i:=1 to n do
If a[i] mod 2 = 0 then sc:=sc+a[i];
Writeln(sc);
Write('Tong cac so le la ');
For i:=1 to n do
If a[i] mod 2 <> 0 then sl:=sl+a[i];
Write(sl);
Readln
End.
BT1:
Uses crt;
var i,n: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
writeln(a[i]:3);
readln;
end.
BT2:
Uses crt;
var i,n,k: integer;
a: array[1..100] of longint;
begin clrscr;
readln(n);
for i:=1 to n do
read(a[i]); readln;
for i:=1 to n do begin
if(a[i] mod 2=0) then k:=k+a[i];
end;
writeln(k);
readln;
end.