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.
program trungbinh;
uses crt;
var n,i: integer;
s:real;
A: array[1..1000] of integer;
begin
clrscr;
write('Nhap do dai day: '); readln(n);
writeln('Nhap gia tri cua day: ');
S:=0;
for i:=1 to n do
begin
write('A[',i,']= ');
readln(A[i]);
S:=S+A[i];
end;
S:=S/n;
write('Trung binh cua cac so cua day do la: ',S);
readln;
end.
Bài 1:
uses crt;
var a:array[1..100]of integer;
i,n,min:integer;
begin
clrscr;
write('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];
writeln(min);
readln;
end.
Bài 2:
uses crt;
var a:array[1..100]of integer;
i,n,max:integer;
begin
clrscr;
write('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];
writeln(max);
readln;
end.
Program HOC24;
var a: array[1..32000] of integer;
i,n,d: integer;
begin
write('Nhap N: ');
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Day vua nhap la: ');
for i:=1 to n do write(a[i],' '); writeln;
d:=0;
for i:=1 to n do if a[i]>0 then d:=d+1;
write('Co ',d,' so duong');
readln
end.
#include <bits/stdc++.h>
using namespace std;
long long i,n;
double s;
int main()
{
cin>>n;
s=0;
for (i=1; i<=n; i++)
s=s+((1*1.0)/(2*(i*1.0+1*1.0)));
cout<<fixed<<setprecision(2)<<s;
return 0;
}
Program HOC24;
var n,d,i: integer;
B: array[1..100] of integer;
t: longint;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('B[',i,']='); readln(b[i]);
end;
d:=0; t:=0;
for i:=1 to n do
if b[i]>0 then
begin
d:=d+1;
t:=t+b[i];
end;
writeln('Tong cac so duong trong day so la: ',t);
write('Co ',d,' so duong trong day');
readln
end.
uses crt;
var b:array[1..100] of longint;
n,i,d,s:longint;
begin
clrscr;
write('n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']: '); readln(b[i]);
if b[i]>0 then begin
inc(d);
inc(s,b[i]);
end;
end;
writeln('Tong cac so duong: ',s);
writeln('Co ',d,' so duong');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,n,i,ln,t;
int main()
{
cin>>n;
ln=LLONG_MIN;
t=0;
for (i=1; i<=n; i++)
{
cin>>x;
ln=max(ln,x);
t+=x;
}
cout<<"So lon nhat la: "<<ln<<endl;
cout<<"Tong la: "<<t;
return 0;
}
program Le_Nho_Hon_Hoac_Bang_n;
uses crt;
var
n, i: integer;
begin
clrscr;
write('Nhap vao mot so nguyen duong n: ');
readln(n);
while n <= 0 do
begin
writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');
readln(n);
end;
clrscr;
writeln('Cac so le nho hon hoac bang ', n, ' la:');
i := 1;
while i <= n do
begin
if i mod 2 <> 0 then
writeln(i);
i := i + 1;
end;
readln;
end.
Program HOC24;
var a: array[1..32000] of integer;
i,max,min,n: integer;
begin
write('Nhap so phan tu N: '); readln(N);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
max:=a[1]; min:=a[1];
for i:=1 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('So nho nhat la :',max);
write('So lon nhat la: ',min);
readln
end.
uses crt;
var a:array[1..100]of integer;
i,n,max,min: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];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('So lon nhat la: ',max);
writeln('So nho nhat la: ',min);
readln;
end.
a)
uses crt;
var a:array[1..100]of integer;
i,n,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];
writeln(max);
readln;
end.
b)
uses crt;
var a:array[1..100]of integer;
i,n,min: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];
writeln(min);
readln;
end.
uses crt;
var n,i,d,x,j,tam:longint;
a:array[1..11]of integer;
st:string;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until n>0;
str(n,st);
d:=length(st);
for i:=1 to d do
begin
val(st[i],a[i],x);
end;
for i:=1 to d-1 do
for j:=i+1 to d do
if a[i]<a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to d do
write(a[i]);
readln;
end.