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.
uses crt;
var a:array[1..100]of integer;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
Câu 1:
uses crt;
var a:array[1..100]of integer;
n,i,tl,tc:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
tc:=0;
tl:=0;
for i:=1 to n do
begin
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 so nguyen chan cua day la: ',tc);
writeln('tong so nguyen le cua day la: ',tl);
readln;
end.
Câu 2:
uses crt;
var a:array[1..100]of integer;
n,i:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly-----------------------------}
writeln('cac so nguyen am co trong day la: ');
for i:=1 to n do
if a[i]<0 then write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly-----------------------------}
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('tong cac phan tu chia het cho 3 la: ',t);
readln;
end.
Câu 4:
uses crt;
var a,vt:array[1..100]of integer;
n,i,t,dem,j:integer;
min:int64;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
min:=maxint;
for i:=1 to n do
if min>a[i] then min:=a[i];
dem:=0;
for i:=1 to n do
if a[i]=min then
begin
inc(dem);
vt[dem]:=i;
end;
writeln('so nho nhat la: ',min);
writeln('vi tri cua no trong day lan luot la: ');
for j:=1 to dem do
write(vt[j]:4);
readln;
end.
Câu 5:
uses crt;
var a,vt:array[1..100]of integer;
n,i,j,tam:integer;
begin
clrscr;
repeat
write('nhap n='); readln(n);
if (n<=0) or (n>100) then writeln('ban da nhap sai, yeu cau ban nhap lai');
until (0<n) and (n<=100);
for i:=1 to n do
begin
repeat
write('a[',i,']='); readln(a[i]);
if abs(a[i])>=1000 then writeln('vui long nhap so co gia tri tuyet doi nho hon 1000');
until abs(a[i])<1000;
end;
{--------------------------xu-ly-----------------------------}
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;
writeln('day so giam dan la: ');
for i:=1 to n do
write(a[i]:4);
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.
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.
Câu 1:
var a:array[1..100]of integer;
Câu 2:
uses crt;
var a:array[1..10]of integer;
i:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to 10 do
write(a[i]:4);
readln;
end.
Câu 3:
uses crt;
var a:array[1..15]of integer;
i,n,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=15);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until a[i]<=100;
end;
writeln('Mang da nhap la: ');
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('Tong cac phan tu chia het cho 3 la: ',t);
writeln('Cac so chan o vi tri le trong day la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (i mod 2=1) then write(a[i]:4);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem1,dem2,t1,dem3,j,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
dem1:=0;
dem2:=0;
t1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem1:=dem1+1;
t1:=t1+a[i];
end;
else dem2:=dem2+1;
end;
dem3:=0;
for i:=1 to n do
if (a[i]>1) then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then dem3:=dem3+1;
end;
writeln(dem1, ' ',dem2);
writeln(t1);
writeln(dem3);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,t,dem;
int main()
{
cin>>n;
t=0;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0)
{
dem++;
t=t+x;
}
cout<<t<<" "<<dem;
return 0;
}
}
uses crt;
var a:array[1..100]of integer;
n,i,k,dem,dem1: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);
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then inc(dem);
if a[i] mod k=0 then inc(dem1);
end;
writeln('So phan tu chan la: ',dem);
writeln('So phan tu chia het cho ',k,' la: ',dem1);
readln;
end.
Program HOC24;
var i,n: byte;
A: array[1..100] of integer;
t: longint;
begin
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 then t:=t+a[i];
write('Tong cac so chan la: ',t);
readln
end.