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.
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.
Câu 1:
uses crt;
var a:array[1..500]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]<0) and (a[i] mod 7=0) then t:=t+a[i];
writeln('Tong cac so am chia het cho 7 la: ',t);
readln;
end.
Câu 2:
uses crt;
var c,a:array[1..10]of integer;
i,kt,j,dem:integer;
begin
clrscr;
for i:=1 to 10 do
begin
write('C[',i,']='); readln(c[i]);
end;
dem:=0;
for i:=1 to 10 do
if c[i]>1 then
begin
kt:=0;
for j:=2 to c[i]-1 do
if c[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
a[dem]:=c[i];
end;
end;
if dem=0 then writeln('Trong day khong co so nguyen to')
else begin
writeln('Cac so nguyen to trong day la: ');
for i:=1 to dem do
write(a[i]:4);
end;
readln;
end.
Câu 3:
uses crt;
var d:array[1..200]of integer;
i,k,dem:integer;
begin
clrscr;
write('Nhap k='); readln(k);
for i:=1 to k do
begin
write('D[',i,']='); readln(d[i]);
end;
dem:=0;
for i:=1 to k do
if (a[i] mod 2=0) and (a[i]>=10) then inc(dem);
writeln('So phan tu chan co 2 chu so la: ',dem);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,dem,t,tb: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]>0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('So luong phan tu duong la: ',dem);
writeln('Tong cac phan tu duong la: ',t);
writeln('Trung binh cac phan tu duong la: ',t/dem:4:2);
readln;
end.
Mình chỉ viết chương trình chính thôi, còn chương trình con bạn tự viết nhé
uses crt;
var a:array[1..100]of integer;
i,n,t,t1,t2:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
edn;
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
int A[500],n,i,dem,dem1;
int main()
{
cin>>n;
for (int i=1; i<=n; i++) cin>>A[i];
for (int i=n; i>=1; i--) cout<<A[i]<<" ";
cout<<endl;
dem=0;
for (int i=1; i<=n; i++)
if (A[i]<10) dem++;
cout<<dem<<endl;
dem1=0;
for (int i=1; i<=n; i++)
if (A[i]>1)
{
bool kt=true;
for (int j=2; j*j<=A[i]; j++)
if (A[i]%j==0) kt=false;
if (kt==true) dem1++;
}
cout<<dem1;
return 0;
}
a)
Type mang=array[1..100]of integer;
procedure nhap(var a:mang);
var n,i:integer;
begin
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
end;
b) procedure xuat(var a:mang);
var i,n:integer;
begin
for i:=1 to n do
if a[i] mod 2=0 then write(a[i]:4);
end;
#include <bits/stdc++.h>
using namespace std;
long long a[1000],n,i,dem,t,j,t1;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) cout<<a[i]<<" ";
cout<<endl;
dem=0;
for (i=1; i<=n; i++)
{
t=0;
for (j=1; j<=a[i]-1; j++)
if (a[i]%j==0) t+=j;
if (t==a[i]) dem++;
}
cout<<dem<<endl;
t1=0;
for (i=1; i<=n; i++)
if (a[i]%2==0) t1+=a[i];
cout<<t1;
return 0;
}
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.
uses crt;
var a:array[1..10]of longint;
n,i,t,dem,dem1,dem2,t1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
t1:=0;
dem1:=0;
dem2:=0;
for i:=1 to n do
begin
if a[i]>0 then dem1:=dem+1;
if a[i] mod 2=0 then
begin
dem2:=dem2+1;
t1:=t1+a[i];
end;
end;
writeln(dem1);
writeln(t1/dem2:4:2);
readln;
end.
program cau_a;
uses crt;
type mang=array[1..100]of integer;
var a:mang;
i,n:integer;
s:longint;
{------------------chuong-trinh-con-nhap--------------}
procedure nhap(var b:mang);
begin
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(b[i]);
end;
end;
{---------chuong-trinh-con-tim-min--------------}
function min(var c:mang):integer;
var j,m,nn:integer;
begin
nn:=c[1];
for j:=1 to m do
if nn<c[j] then nn:=c[j];
write('so nho nhat trong mang A la: ',nn);
min:=nn;
end;
{-----------------chuong-trinh-chinh---------------------}
begin
clrscr;
nhap(a);
min(a);
readln;
end.
câu b:
program cau_b;
uses crt;
type mang=array[1..100]of integer;
var a:mang;
i,n:integer;
s:longint;
{------------------chuong-trinh-con-nhap--------------}
procedure nhap(var b:mang);
begin
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(b[i]);
end;
end;
{---------chuong-trinh-con-tinh-tong-cac-phan-tu-la-so-chan--------}
function tong(var c:mang):integer;
begin
s:=0;
for i:=1 to n do
if c[i] mod 2=0 then s:=s+c[i];
tong:=s;
end;
{-----------------chuong-trinh-chinh---------------------}
begin
clrscr;
nhap(a);
s:=tong(a);
write(s);
readln;
end.