viết chương trình nhập vào mảng n số nguyên in ra màn hình những số chia hết cho 5
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 a: array[1..15] of integer;
i: byte;
t: longint;
begin
for i:=1 to 15 do
begin
write('Nhap phan tu thu ',i,': '); readln(a[i]);
end;
t:=0;
write('Cac so chia het cho 5 la: ');
for i:=1 to 15 do if a[i] mod 5=0 then
begin
write(a[i].' ');
t:=t+a[i];
end;
writeln;
write('Tong cac so chia het cho 5 la: ',t);
readln
end.
uses crt;
var a:array[1..100]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;
for i:=1 to n do
write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long a[10000],n,i,t;
int main()
{
cin>>n;
t=0;
for (i=1; i<=n; i++)
{
cin>>a[i];
t=t+a[i];
}
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
if (a[i] %2==0) dem++;
cout<<dem<<endl;
cout<<t;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long a[10],i,dem;
int main()
{
for (i=1; i<=10; i++) cin>>a[i];
for (i=1; i<=10; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=10; i++) if (a[i]%3==0) dem++;
cout<<dem;
return 0;
}
Var a:array[1..200] of integer;
i,n:integer;
begin
write('Nhap so luong phan tu n = ');readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' = ');readln(a[i]);
end;
writeln('Cac so chia het cho 3 la ');
for i:=1 to n do
if a[i] mod 3 = 0 then write(a[i],' ');
readln;
end.
Bài 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 5=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 5 la: ',t);
readln;
end.
Bài 2:
uses crt;
var st:string;
d,i:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if st[i]=#32 then delete(st,i,1);
writeln(st);
readln;
end.
Uses crt;
Var a:array[1..6] of integer;
I,t:integer,
Begin
Clrscr;
For i:=1 to 6 do
Begin
Write('a[',i,']='); readln(a[i]);
End,
T:=0;
For i:=1 to 6 do
If (a[i] mod 3=0) and (a[i] mod 5=0) then t:=t+a[i];
Writeln(t);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
n,i,t,nn,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=1;
for i:=1 to n do
if a[i] mod 3=0 then t:=t*a[i];
writeln(t);
kt:=0;
nn:=32567;
for i:=1 to n do
if a[i] mod 3=0 then
begin
if nn>a[i] then nn:=a[i];
kt:=1;
end;
if kt=0 then writeln('Khong co so chia het cho 3')
else writeln('So nho nhat chia het cho 3 la: ',nn);
for i:=1 to n do
if nn=a[i] then write(i:4);
writeln;
for i:=n downto 1 do
write(a[i]:4);
readln;
end.
Program Tin;
Uses crt;
Var i,n:integer;
A:array[1..1000] of integer;
Begin
Clrscr;
Write('Nhap n: ');readln(n);
Writeln('Nhap ',n,' phan tu: ');
For i:= 1 to n do
Begin
Write('A[',i,'] = ');
Readln(A[i]);
End;
Writeln('Cac phan tu chia het cho 5:');
For i:=1 to n do If A[i] mod 5 = 0 then write(A[i],' ');
readln;
end.
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 5=0 then write(a[i]:4);
readln;
end.