Trở về đầu

foto1 foto2 foto3 foto4 foto5
Giảng viên
Nguyễn Tô Sơn - Thủ khoa Đại học Sư phạm Hà Nội
ĐT: 091.333.2869

HỌC TIN CÙNG THỦ KHOA

Thành công không phải đích đến, mà là cả một hành trình

Tìm kiếm

Sắp xếp

#include <bits/stdc++.h>

using namespace std;

const double epsilon = 1e-7;
const int maxn = 100;
struct data
{
    string name;
    int64_t SBD;
    double van, toan, sum;
};
int n;
data a[maxn];

void Enter()
{
    freopen("diem.inp", "r", stdin);
    freopen("diem.out", "w", stdout);
    cin >> n;
    cin.ignore(1);
    for (int i = 1; i <= n; i++)
    {
        getline(cin, a[i].name);
        cin >> a[i].SBD >> a[i].toan >> a[i].van;
        cin.ignore(1);
        a[i].sum = a[i].van + a[i].toan;
    }
}

bool cmp(data x, data y)
{
    if (x.sum > y.sum)
        return true;
    else
        return false;
}

void Solve()
{
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++)
        printf("%-15s \t%lld\t%0.2lf \t %0.2lf \t %0.2lf\n", a[i].name.c_str(), a[i].SBD, a[i].toan, a[i].van, a[i].sum);
}

int main()
{
    Enter();
    Solve();
    return 0;
}

Giảng viên Nguyễn Tô Sơn, Thủ khoa Đại học Sư phạm Hà Nội. Điện thoại: 091.333.2869