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.
![](https://rs.olm.vn/images/avt/0.png?1311)
Tham Khảo:
uses crt;
var a:array[1..100]of integer;
i,n,j,tam:integer;
begin
clrscr;
write('Nhap n='); readln(n);</p><p>for i:=1 to n do</p><p> begin</p><p>write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(a[i]:4);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,t;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
t=0;
for (i=1; i<=n; i++)
if (i%3==0) t+=i;
cout<<t<<endl;
for (i=1; i<=n; i++)
if (a[i]<0) cout<<a[i]<<" ";
return 0;
}
![](https://rs.olm.vn/images/avt/0.png?1311)
Chương trình đầy đủ:
uses crt;
var n,i:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
if n mod i=0 then write(i:4);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
uses crt;
var i,n,d:longint;
begin
d:=0;
writeln('nhapn=');read(n);
for i:=1 to n do
begin
if i mod 3=0 then write(i,' ');
if i mod 3=0 then d:=d+i;
end;
writeln('tong=',d);
readln;
end;
![](https://rs.olm.vn/images/avt/0.png?1311)
Câu 1: Viết chương trình nhập vào N số nguyên từ bàn phím tính tích các số chia hết cho 3?
program TichSoChiaHetCho3;
var
n, i, tich: integer;
a: array[1..100] of integer;
begin
tich := 1;
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]);
if a[i] mod 3 = 0 then
begin
tich := tich * a[i];
end;
end;
writeln('Tich cac phan tu chia het cho 3 la: ', tich);
readln;
end.
Câu 2: Viết chương trình nhập vào N số nguyên từ bàn phím đếm xem có bao nhiêu số chẵn trong các số vừa nhập?
program DemSoChanTrongDay;
var
n, i, tich: integer;
a: array[1..100] of integer;
begin
dem := 0;
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]);
if a[i] mod 2 = 0 then
begin
dem := dem + 1;
end;
end;
writeln('So phan tu chan trong day la: ', dem);
readln;
end.
Câu 3: Viết chương trình nhập vào N số nguyên từ bàn phím hiển thị các số có giá trị nhỏ hơn hoặc bằng 20?
program HienThiSoNhoHon20;
var
n, i: integer;
a: array[1..100] 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]);
if a[i] <= 20 then
begin
writeln(a[i]);
end;
end;
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
program TinhTong;
uses crt;
var
n, i, tong: integer;
begin
clrscr;
write('Nhap vao so nguyen duong n: ');
readln(n);
tong := 0;
for i := 1 to n-1 do begin
if i mod 2 <> 0 then
tong := tong + i;
end;
writeln('Tong cac so khong chia het cho 2 la: ', tong);
readln;
end.
![](https://rs.olm.vn/images/avt/0.png?1311)
Bạn Akai làm thiếu rồi, mình xin bổ sung một chút cho nó hoàn thiện bài nhé:
uses crt;
var a:array[1..100]of integer;
i,n,t1,t2,t3: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
write(a[i]:4);
writeln;
t1:=0;
t2:=0;
t3:=0;
for i:=1 to n do
begin
if a[i]>0 then t1:=t1+a[i];
if a[i] mod 2<>0 then t2:=t2+a[i];
if a[i] mod 2=0 then t3:=t3+a[i];
end;
writeln('Tong cac so duong la: ',t1);
writeln('Tong cac so le la: ',t2);
writeln('Tong cac so chan la: ',t3);
readln;
end.
uses crt;
Var a:array[1..100000] of longint;
i,n,d:longint;
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) and (a[i] mod 3=0) then inc(d);
write('Co ',d,' so vua chia het cho 2 vua chia het cho 3');
readln
end.