Thứ Tư, 27 tháng 4, 2022

NHIETDO C++

#include <bits/stdc++.h>
using namespace std;

int a[8],s,d;
float tb;
void nhap()
{
    for(int i=1;i<=7;i++) 
        cin>>a[i];
}
void tinhtb()
{
    s=0;
    for(int i=1;i<=7;i++) s=s+a[i];
    tb=float(s)/7;
    cout<<fixed <<setprecision(2);
    cout<<tb;
}
void dem()
{
    d=0;
    for(int i=1;i<=7;i++)
        if(a[i]>tb) d++;
    cout<<d;
}
int main()
{
    freopen("nhietdo.inp","r",stdin);
    freopen("nhietdo.out","w",stdout);
    nhap();
    tinhtb();
    dem();
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.