Untitled
raw download clone
CPP
views 41
,
size 980 b
#include <iostream>
#include <cstring>
using namespace std;

struct elev
{
    char nume[51];
    char prenume[51];
    int nota1, nota2;
    float medie;
}v[101];

int main ()
{
    int n, N;
    int cnt = 0, k = 0;
    cin >> n >> N;

    for(int i = 1; i <= n; i++)
    {
        cin >> v[i].nume >> v[i].prenume >> v[i].nota1 >> v[i].nota2;
        v[i].medie = (v[i].nota1 + v[i].nota2) / 2.;
        if(v[i].medie >= 6)
            k++;
    }

    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
            if(v[i].medie < v[j].medie)
                swap(v[i], v[j]);

    for(int i = 1; i < N; i++)
        for(int j = i + 1; j <= N; j++)
            if(strcmp(v[i].nume, v[j].nume) > 0)
                swap(v[i], v[j]);

    for(int i = 1; i <= N; i++)
    {
        if(v[i].medie < 6)
            cnt++;
        else
            cout << v[i].nume << ' ' << v[i].prenume << '\n';
    }
    cout << cnt;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.