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.
Câu 4:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if (10<a[i]) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So phan tu lon hon 10 va nho hon 20 la: ',dem);
writeln('Tong cac phan tu lon hon 10 va nho hon 20 la: ',t);
readln;
end.
Câu 5:
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
inc(dem);
t:=t+a[i];
end;
writeln('So so chan la: ',dem);
writeln('Tong cac so chan la: ',t);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem: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 (10<a[i]) and (a[i]<20) then inc(dem);
writeln(dem);
readln;
end.
uses crt;
var a,b,c:array[1..100]of integer;
i,n,dem,dem1:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
dem1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
inc(dem);
b[dem]:=a[i];
end
else begin
ic(dem1);
c[dem1]:=a[i];
end;
end;
writeln('Co ',dem,' so chan');
writeln('Co ',dem1,' so le');
if dem>0 then
begin
write('Cac so chan la: ');
for i:=1 to dem do
write(b[i]:4);
end;
if dem1>0 then
begin
write('Cac so le la: ');
for i:=1 to dem1 do
write(c[i]:4);
end;
readln;
end.
program TimMinMaxTrungBinh;
var
N, i, max, min, sum: integer;
a: array[1..50] of integer;
TB, minTB, maxTB: real;
begin
writeln('Nhap so nguyen duong N:');
readln(N);
sum := 0;
for i := 1 to N do
begin
write('Nhap so thu ', i, ': ');
readln(a[i]);
sum := sum + a[i];
end;
max := a[1];
min := a[1];
for i := 2 to N do
begin
if a[i] > max then
max := a[i];
if a[i] < min then
min := a[i];
end;
TB := sum / N;
minTB := TB;
maxTB := TB;
for i := 1 to N do
begin
if (a[i] < TB) and (a[i] < minTB) then
minTB := a[i];
if (a[i] > TB) and (a[i] > maxTB) then
maxTB := a[i];
end;
writeln('Gia tri lon nhat la: ', max);
writeln('Gia tri nho nhat la: ', min);
writeln('Gia tri trung binh la: ', TB:2:2);
if minTB = TB then
writeln('Khong co gia tri nao nho hon TB')
else
writeln('Gia tri nho nhat < TB la: ', minTB);
if maxTB = TB then
writeln('Khong co gia tri nao lon hon TB')
else
writeln('Gia tri lon nhat > TB la: ', maxTB);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n,kt,j;
int main()
{
cin>>n;
for (i=2; i<=n; i++)
{
kt=0;
for (j=2; j*j<=i; j++)
if (i%j==0) kt=1;
if (kt==0) cout<<i<<" ";
}
return 0;
}
1:
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
2:
uses crt;
var n,dem,i,t:integer;
a:array[1..100]of integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly----------------------------}
dem:=0;
t:=0;
for i:=1 to n do
if (a[i]>10) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('so cac so lon hon 10 va nho hon 20 la: ',dem);
writeln('tong cua chung la: ',t);
readln;
end.
1:
uses crt;
var st:string;
dem,i,d:integer;
begin
clrscr;
write('st='); readln(st);
d:=length(st);dem:=0;
for i:=1 to d do
if st[i] in['0'..'9'] then inc(dem);
writeln(dem);
readln;
end.
2:
uses crt;
var n,dem,i,t:integer;
a:array[1..100]of integer;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
{--------------------------xu-ly----------------------------}
dem:=0;
t:=0;
for i:=1 to n do
if (a[i]>10) and (a[i]<20) then
begin
inc(dem);
t:=t+a[i];
end;
writeln('so cac so lon hon 10 va nho hon 20 la: ',dem);
writeln('tong cua chung la: ',t);
readln;
end.