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.
#include <bits/stdc++.h>
using namespace std;
double a[1000],t;
int n,i;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
t=0;
for (i=1; i<=n; i++) t+=a[i];
cout<<fixed<<setprecision(2)<<t/(n*1.0);
return 0;
}
Var a:array:[1..1000] of real;
i,n:integer;
max,min,s,tb:real;
Begin
Write('Nhap so luong hoc sinh: ');readln(n);
For i:=1 to n do
Begin
Write('Nhap chieu cao hs thu ',i,' = ');readln(a[i]);
s:=s+a[i];
End;
tb:=s/n;
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;
writeln('Chieu cao lon nhat la ',max:10:1);
Writeln('Chieu cao nho nhat la ',min:10:1);
Write('Chieu cao trung binh la ',tb:10:1);
Readln
End.
a)
var a:array[1..100] of longint;
n,i,max,d:longint;
begin
read(n);
for i:=1 to n do
write('nhap chieu cao, don vi cm');read(a[i]);
b) max:=a[1];
for i:=2 to n do
if a[i]>max then max:=a[i];
writeln('ban cao nhat cao',max);
c) for i:=1 to n do
if a[i]>160 then d:=d+1;
write('so ban cao hon 160 cm la: ',d);
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;
}
2:
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n;
int main()
{
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++) if (a[i]%2==0) cout<<a[i]<<" ";
return 0;
}
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.
uses crt;
var a:array[1..60[of real;
i,n:integer;
begin
clrscr;
write('Nhap so ban:'); readln(n);
for i:=1 to n do
begin
write('Chieu cao cua ban thu ',i,' la: '); readln(a[i]);
end;
for i:=1 to n do
writeln('Ban thu ',i,' cao ',a[i],'m');
readln;
end.