Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- struct student {
- string famil, imya, otch;
- int chisl, mec, year;
- int oc1, oc2, oc3, oc4, oc5;
- int summa();
- };
- int student::summa() {
- return oc1 + oc2 + oc3 + oc4 + oc5;
- }
- /*void sort_puz(student* y, int n) {
- student temp;
- int i, j;
- for (i = 0; i < n - 1; i++) {
- for (j = n - 1; j > i; j--) {
- if (y[j].summa() > y[j - 1].summa()) {
- temp = y[j];
- y[j] = y[j - 1];
- y[j - 1] = temp;
- }
- if ((y[j].summa() == y[j - 1].summa()) && (y[j].famil < y[j - 1].famil)) {
- temp = y[j];
- y[j] = y[j - 1];
- y[j - 1] = temp;
- }
- }
- }
- }
- */
- /*void sort_vib(student* y, int n) {
- student temp;
- for (int i = 0; i < n - 1; i++) {
- int lowindex = i;
- int lowkey = y[i].summa();
- for (int j = i; j < n; j++) {
- if (y[j].summa() > lowkey) {
- lowkey = y[j].summa();
- lowindex = j;
- }
- }
- temp = y[i];
- y[i] = y[lowindex];
- y[lowindex] = temp;
- }
- }
- */
- void sort_vst(student* y, int n) {
- student temp;
- for (int i = 1; i < n; i++) {
- int j = i;
- while (j > 0 and y[j].summa() > y[j-1].summa()) {
- temp = y[j];
- y[j] = y[j-1];
- y[j-1] = temp;
- j--;
- }
- }
- }
- int main() {
- int n, k;
- in >> n >> k;
- student* t = new student[k];
- for (int i = 0; i < k; i++) {
- in >> t[i].famil >> t[i].imya >> t[i].otch >> t[i].chisl >> t[i].mec >> t[i].year >> t[i].oc1 >> t[i].oc2 >> t[i].oc3 >> t[i].oc4 >> t[i].oc5;
- }
- //sort_puz(t, k);
- //sort_vib(t, k);
- sort_vst(t, k);
- for (int i = 0; i < k; i++) {
- out << t[i].summa() << endl;
- }
- }
- // 141 7
- Иванов Иван Иванович 10 2 2007 3 4 5 4 5
- Петров Петр Петрович 10 6 2007 2 4 3 3 3
- кто-то кто-то кто-то 24 7 2004 4 4 4 5 5
- я я я 15 9 2003 5 5 5 5 5
- Ложкова Александра Сергеевна 4 4 2005 3 4 3 5 3
- Хусаинова Дарья Алексеевна 22 12 2005 5 5 5 5 5
- Парамонова Мария Дмитриевна 6 4 2008 4 4 4 5 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement