VCT nhập vào 1 dãy,rồi kiểm tra xem dãy ấy có thể chia hết cho 2 và 5 ko?
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.
var n,i,k,d: integer;
a:array[1..52] of integer;
begin
write('Nhap so N: '); readln(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
write('Nhap so k: '); readln(k);
d:=0;
for i:=1 to n do
if a[i] mod k = 0 then d:=d+1;
writeln('Co ',d,' so chia het cho ',k,' trong day');
if d mod 2 = 0 then writeln('Chan') else writeln('Le');
end.
uses crt;
var a:array[1..52]of integer;
i,n,k,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=52);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
dem:=0;
for i:=1 to n do
if a[i] mod k=0 then inc(dem);
writeln('Trong day co ',dem,' so chia het cho ',k);
if dem mod 2=0 then writeln('So luong so chia het cho ',k,' la so chan')
else writeln('So luong so chia het cho ',k,' la so le');
readln;
end.
Program HOC24;
var i,n,d: integer;
a: array[1..1000] of integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
d:=0;
for i:=1 to n do if a[i] mod 5<>0 then d:=d+1;
write('Co ',d,' so khong chia het cho 5');
readln
end.
1.
Program HOC24;
var a: array[1..32000] of longint;
i,n: integer;
tc,tl: longint;
begin
write('Nhap N: '); readln(n);
tc:=0; tl:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] mod 2=0 then tc:=tc+a[i];
if a[i] mod 2=1 then tl:=tl+a[i];
end;
writeln('Tong chan la: ',tc);
write('Tong le la: ',tl);
readln
end.
2.
Program HOC24;
var a: array[1..32000] of longint;
d1,d2,i,n: integer;
begin
write('Nhap N: '); readln(n);
d1:=0; d2:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if a[i] >0 then d1:=d1+1;
if a[i] <0 then d2:=d2+1;
end;
writeln('Co ',d1,' so lon hon 0');
write('Co ',d2,' so be hon 0');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long n,a[1000],m,i;
bool kt;
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
cin>>m;
kt=false;
for (i=1; i<=n; i++)
if (a[i]==m) kt=true;
if (kt==true) cout<<"Co";
else cout<<"Khong";
return 0;
}
Bài 1:
program in_phan_tu;
uses crt;
var n,i:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
for i:=1 to n do
write(a[i]:3);
readln;
end.
Bài 2:
program tong_phan_tu;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Bài 3:
program tong_phan_tu_chan;
uses crt;
var n,i,tong:longint;
a:array[1..100] of longint;
begin
clrscr;
write('nhap so n:');readln(n);
for i:=1 to n do
begin
write('nhap phan tu a[',i,']:');readln(a[i]);
end;
tong:=0;
for i:=1 to n do
if a[i] mod 2=0 then tong:=tong+a[i];
writeln('tong cua day la:');
readln;
end.
Câu 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
write(a[i]:4);
readln;
end.
Bài 1:
Program HOC24;
var a: array[1..1000] of integer;
i,n,d: integer;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
for i:=1 to n do if (a[i]<0) and (a[i] mod 2=0) then d:=d+1;
write('Co ',d,' so nguyen am chan trong day so');
readln
end.
Bài 2:
Program HOC24;
var a: array[1..1000] of integer;
i,n: integer;
t: longint;
begin
write('Nhap so phan tu: '); readln(n);
for i:=1 to n do
begin
write('Nhap so thu ',i,': '); readln(a[i]);
end;
t:=0;
for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i];
write(Tong la: ',t);
readln
end.