K
Khách

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.

1 tháng 2 2019

(số vừa chia hết cho 2 mà vừa chia hết cho 3 thì sẽ chia hết cho 6)

var array: K[1..100] of integer;

array: T[1...100] of integer;

j,i,n: integer;

begin

writeln ('nhap n'); readln (n);

repeat

writeln ('nhap lai'); readln(n);

until (n<100);

j:=1;

for i:= 1 to n do

begin

writeln ('nhap phan tu thu ',i); readln (k[i]);

if k[i] mod 6 = 0 then

begin

t[j]:=k[i];

j:=j+1;

end;

end;

for i:= 1 to j do

if i mod 10 = 0 then writeln(t[i]) else write(t[i],' ');

readln;

end.

(vì bảng mình không biết là bao nhiêu số 1 dòng nên mình lấy đại 10 nha, mình chỉ học mảng 1 chiều)

2 tháng 2 2019

cho mình sửa lại câu lệnh for là

for i:=1 to j-1 do ...

(xin lỗi bạn vì mình có sai sót nhưng mong là hết sai rồi :)))

18 tháng 3 2023

N = int(input("Nhập số lượng phần tử của dãy N (>50): "))

while N <= 50:

         N = int(input("Nhập lại số lượng phần tử của dãy N (>50): "))

# Nhập vào dãy số 

danh_sach = []

for i in range(N):

         danh_sach.append(int(input("Nhập số thứ %d: " % (i+1))))

# In ra dãy số vừa nhập

print("Dãy số vừa nhập:")

for i in danh_sach:

         print(i, end=' ')

# Nhập vào số nguyên x

x = int(input("nNhập vào số nguyên x: "))

# In ra các số chia hết cho x 

print("Các số chia hết cho x là:")

for i in danh_sach:

         if i % x == 0:

                  print(i, 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;

t:=0;

for i:=1 to n do 

  if (a[i] mod 2=0) and (a[i] mod 3=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..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. 

14 tháng 3 2018

program bai_tap;
var i,d:integer;
begin
d:=0;
for i:= 100 to 999 do
begin
if (i mod 2 = 0) and (i mod 3 = 0) and (i mod 5 = 0 ) then
begin
write(i,' ');
inc(d);
end;
if d = 5 then
begin
d:=0;
writeln;
end;
end;
readln
end.

17 tháng 1 2018

program bai1;

var a,b,c:longint;

begin

for a:=1 to 9 do

for b:=0 to 9 do

for c:=0 to 9 do

if (((a*100+b*10+c) mod 2=0) and ((a*100+b*10+c) mod 3=0) and ((a*100+b*10+c) mod 5=0)) then write(a*100+b*10+c);

readln

end.

24 tháng 11 2021

bprogram min 

uses crt 

var A: array [1...250] of integer

tong :integer;

begin 

tong:=0

writeln(‘nhap n:’); readln (n) 

forr i:=1 to n do 

begin 

writeln (‘nhap phan tu thu ‘,i);

readln (A[i] );

end

for i:=1 to n do 

begin

if (A[i] mod 3=0) 

then tong:=tong +A[i];

end

writeln (Tong cac phan tu chia het cho 3) 

readln ;

end

24 tháng 11 2021