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,dem:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<=n) and (n<=1000);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Mang ban vua nhap la: ');
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then inc(dem);
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,kt,dem,j:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=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
begin
kt:=1;
break;
end;
if kt=0 then inc(dem);
end;
writeln('So phan tu la so nguyen to la: ',dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,t,max:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
for i:=1 to n do
if max<a[i] then max:=a[i];
t:=0;
for i:=1 to n do
if max=a[i] then t:=t+a[i];
writeln('Tong cac phan tu co gia tri lon nhat la: ',t);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem,t:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<=1000);
for i:=1 to n do
begin
repeat
write('A[',i,']='); readln(a[i]);
until abs(a[i])<=1000;
end;
for i:=1 to n do
write(a[i]:4);
writeln;
dem:=0;
for i:=1 to n do
if a[i]=0 then inc(dem);
writeln('So phan tu bang 0 la: ',dem);
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then t:=t+a[i];
writeln('Tong cac phan tu chan la: ',t);
readln;
end.
var a:array[1..100] of integer;
i,n,S,d:byte;
begin
write(' n = '); readln(n);
for i:=1 to n do begin
write('A[',i,'] = ');
readln(A[i]);
end;
d:=0; S:=0;
for i:=1 to n do if A[i] mod 2 = 0 then begin
d:=d+1;
S:=S+A[i];
end;
write('Dãy có ',d,' phần tử là số chẵn và tổng của chúng là : S = ',S);
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,t1,t2,t3;
int main()
{
cin>>n;
t1=0; t2=0; t3=0;
for (i=1; i<=n; i++)
{
cin>>x;
t1+=x;
if (x%2==0) t2+=x;
else t3+=x;
}
cout<<t1<<" "<<t2<<" "<<t3;
return 0;
}
uses crt;
var C : array [1 .. 50] of integer;
i, n : integer;
begin
clrscr;
write('Nhap so phan tu : '); readln(n);
write('Nhap day gom ', n ,' so : ');
for i := 1 to n do read(C[i]);
write('Cac gia tri chan : ');
for i := 1 to n do
if C[i] mod 2 = 0 then write(C[i], ' ');
readln
end.
uses crt;
var b,a:array[1..100]of integer;
i,n,dem,dem1,dem2,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if b[i]<0 then inc(dem);
if b[i]>0 then inc(dem1);
end;
writeln('So phan tu am la: ',dem);
writeln('So phan tu duong la: ',dem1);
t:=0;
for i:=1 to n do
if b[i]<>0 then t:=t+b[i];
writeln('Trung binh cac phan tu khac 0 trong mang la: ',t/(dem+dem1):4:2);
min:=b[1];
for i:=1 to n do
if min>b[i] then min:=b[i];
dem2:=0;
for i:=1 to n do
if min=b[i] then
begin
inc(dem2);
a[dem2]:=i;
end;
writeln('Gia tri nho nhat la: ',min);
writeln('Chi so la: ');
for i:=1 to dem2 do
write(a[i]:4);
readln;
end.
cau 1:
uses crt;
var a:array[1..100] of integer;
n,i,min: integer;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
min:=a[1];
for i:=2 to n do
if min>a[i] then min=a[i];
writeln(a[i]);
readln;
end.
cau 2:
uses crt;
g:text;
s:string;
const fo='CHUSO.TXT';
begin
assign(g,fo);
rewrite(g);
readln(s);
for i:=1 to length(s) do
if not((s[i] in ['a'..'z'])and(s[i] in ['A'..'Z])) then delete(s,i,1);
writeln(g,s);
end.
uses crt;
var a:array[1..100]of integer;
i,n,min,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
min:=a[1];
for i:=1 to n do
if min>a[i] then min:=a[i];
dem:=0;
for i:=1 to n do
if min=a[i] then inc(dem);
writeln('So phan tu co gia tri nho nhat la: ',dem);
readln;
end.