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..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..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 7=0 then t:=t+a[i];
writeln('Tong cac so chia het cho 7 la: ',t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,k,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
for i:=1 to n do
if a[i] mod k=0 then t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,a[1000],t,dem,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]%2==0) cout<<a[i]<<" ";
cout<<endl;
t=0;
dem=0;
for (i=1; i<=n; i++)
if (a[i]%2==0)
{
t=t+a[i];
dem++;
}
cout<<fixed<<setprecision(2)<<(t*1.0)/(dem*1.0)<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2!=0 || a[i]%3==0) t1+=a[i];
cout<<t1;
return 0;
}
uses crt;
var a:array[1..20]of integer;
i,n,tb,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tb:=0;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
tb:=tb+a[i];
inc(dem);
end;
writeln('Trung binh cong cac so chia het cho 3 la: ',tb/dem:4:2);
readln;
end.
program BaiToanMang;
var
A: array[1..100] of integer;
N, i, demChan, tongLeChia3: integer;
begin
write('Nhap so phan tu cua mang: ');
readln(N);
writeln('Nhap cac phan tu cua mang: ');
for i := 1 to N do
begin
write('a[', i, ']= ');
readln(A[i]);
end;
tongLeChia3 := 0;
for i := 1 to N do
begin
if (A[i] mod 2 = 1) and (A[i] mod 3 = 0) then
begin
tongLeChia3 := tongLeChia3 + A[i];
end;
end;
writeln('Tong cac so le chia het cho 3: ', tongLeChia3);
demChan := 0;
for i := 2 to N do
begin
if (A[i] mod 2 = 0) and (i mod 2 = 1) then
begin
demChan := demChan + 1;
end;
end;
writeln('So phan tu chan o vi tri le: ', demChan);
writeln('Cac so chan chia het cho 5: ');
for i := 1 to N do
begin
if (A[i] mod 2 = 0) and (A[i] mod 5 = 0) then
begin
write(A[i], ' ');
end;
end;
end.
ko bt đúng ko ko dùng pascal nhiều
Var so,n,i:integer;
s:longint;
Begin
Write('n = ');readln(n);
For i:=1 to n do
Begin
Write('Nhap so thu ',i,' = ');readln(so);
If (so mod 3 = 0) and (so mod 5 = 0) then
s:=s+so;
End;
Write('Tong la ',s);
Readln;
End.