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.
Var a:array[1..100] of integer;
i,n:integer;
s:longint;
tbc:real;
Begin
Repeat
Write('n = ');readln(n);
Until (n>0) and (n<=100);
For i:=1 to n do
Begin
Write('Nhap phan tu thu ',i);readln(a[i]);
s:=s+a[i];
End;
tbc:=s/n;
Write('Trung binh cong la ',tbc:10:2);
Readln
End.
Var a:array[1..20] of integer;
max,min:integer;
tbc:real;
Begin
For i:=1 to 20 do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
Max:=a[1];
Min:=a[1];
For i:=2 to 20 do
Begin
If a[i] > max then max:=a[i];
If a[i] < min then min:=a[i];
End;
tbc:=(max+min)/2;
Writeln('So lon nhat la ',max);
Writeln('So nho nhat la ',min);
Write('Trung binh cong la ',tbc:10:2);
Readln;
End.
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
tb:real;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t/n:4:2);
tb:=t/n;
for i:=1 to n do
if a[i]<tb then write(a[i]:4);
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.
Var a:array[1..100] of longint;
tb:real;
i,n:integer;
s:longint;
begin
write('Nhap vao so luong so nguyen '); readln(n);
s:=0;
for i:=1 to n do
begin
write('Nhap vao so thu ',i,' = ');readln(a[i]);
s:=s+a[i];
end;
tb:=s/n;
writeln('Gia tri trung binh cua mang do la ',tb:10:2);
writeln('Cac phan tu lon hon gia tri trung binh la');
for i:=1 to n do
begin
if a[i] > tb then write(a[i]:10);
end;
readln;
end.
Câu 1:
#include <bits/stdc++.h>
using namespace std;
double a,b,c;
int main()
{
cin>>a>>b>>c;
cout<<fixed<<setprecision(2)<<(a+b+c)/3;
return 0;
}
Var a:array[1..20] of integer;
max,min:integer;
tbc:real;
Begin
For i:=1 to 20 do
Begin
Write('Nhap so thu ',i,' = ');readln(a[i]);
End;
Max:=a[1];
Min:=a[1];
For i:=2 to 20 do
Begin
If a[i] > max then max:=a[i];
If a[i] < min then min:=a[i];
End;
tbc:=(max+min)/2;
Writeln('So lon nhat la ',max);
Writeln('So nho nhat la ',min);
Write('Trung binh cong la ',tbc:10:2);
Readln;
End.
Program Trungbinhcong;
Uses crt;
Var a,b,c,d,tb: integer;
Begin
Clrscr;
Write('Nhap so thu nhat:'); Readln(a);
Write('Nhap so thu hai:'); Readln(b);
Write('Nhap so thu ba:'); Readln(c);
Write('Nhap so thu tu:'); Readln(d);
tb:=(a+b+c+d)/4;
Writeln('Trung binh cong cua 4 so la:',tb:4:2);
Readln
End.