#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
struct Elev {
double medie;
char nume[21];
};
void sortare(int n, Elev elevi[30]) {
for (int i = 0; i < n - 1; ++i) {
for (int j = i + 1; j < n; ++j) {
if (elevi[i].medie > elevi[j].medie ||
(elevi[i].medie == elevi[j].medie && strcmp(elevi[i].nume, elevi[j].nume) > 0)) {
Elev temp = elevi[i];
elevi[i] = elevi[j];
elevi[j] = temp;
}
}
}
}
int main() {
int n = 4;
Elev elevi[30] = {
{8.00, "Popescu Ioana"},
{5.00, "Popescu Dani"},
{8.79, "Cristescu Aurel"},
{6.98, "Cristescu Ioan"}
};
sortare(n, elevi);
cout << "Clasamentul elevilor:\n";
for (int i = 0; i < n; ++i) {
cout << fixed << setprecision(2) << elevi[i].medie << " " << elevi[i].nume << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGlvbWFuaXA+IAp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IEVsZXYgewogICAgZG91YmxlIG1lZGllOwogICAgY2hhciBudW1lWzIxXTsKfTsKCnZvaWQgc29ydGFyZShpbnQgbiwgRWxldiBlbGV2aVszMF0pIHsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbiAtIDE7ICsraSkgewogICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47ICsraikgewogICAgICAgICAgICBpZiAoZWxldmlbaV0ubWVkaWUgPiBlbGV2aVtqXS5tZWRpZSB8fCAKICAgICAgICAgICAgICAgIChlbGV2aVtpXS5tZWRpZSA9PSBlbGV2aVtqXS5tZWRpZSAmJiBzdHJjbXAoZWxldmlbaV0ubnVtZSwgZWxldmlbal0ubnVtZSkgPiAwKSkgewogICAgICAgICAgICAgICAgRWxldiB0ZW1wID0gZWxldmlbaV07CiAgICAgICAgICAgICAgICBlbGV2aVtpXSA9IGVsZXZpW2pdOwogICAgICAgICAgICAgICAgZWxldmlbal0gPSB0ZW1wOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbigpIHsKICAgIGludCBuID0gNDsKICAgIEVsZXYgZWxldmlbMzBdID0gewogICAgICAgIHs4LjAwLCAiUG9wZXNjdSBJb2FuYSJ9LAogICAgICAgIHs1LjAwLCAiUG9wZXNjdSBEYW5pIn0sCiAgICAgICAgezguNzksICJDcmlzdGVzY3UgQXVyZWwifSwKICAgICAgICB7Ni45OCwgIkNyaXN0ZXNjdSBJb2FuIn0KICAgIH07CgogICAgc29ydGFyZShuLCBlbGV2aSk7CgogICAgY291dCA8PCAiQ2xhc2FtZW50dWwgZWxldmlsb3I6XG4iOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBjb3V0IDw8IGZpeGVkIDw8IHNldHByZWNpc2lvbigyKSA8PCBlbGV2aVtpXS5tZWRpZSA8PCAiICIgPDwgZWxldmlbaV0ubnVtZSA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9