Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- #include <fstream>
- #include <string>
- using namespace std;
- ifstream in("Input.txt");
- ofstream out("Output.txt");
- struct student
- {
- string fam, name, secondname;
- int mark[5];
- double key;
- void print();
- };
- void student::print()
- {
- out << setw(12) << left << fam << setw(10) << name << setw(15) << secondname;
- for (int i = 0; i < 5; i++)
- out << setw(3) << mark[i];
- out << setw(5) << key << endl;
- }
- void sort(int *a, int n)
- {
- int temp;
- int lowindex, lowkey, i, j;
- for (i = 0; i < n - 1; i++)
- {
- lowindex = i; lowkey = a[j];
- for (j = i + 1; j < n;j++)
- if (a[j] < lowkey)
- {
- lowkey = a[j];
- lowindex = j;
- }
- temp = a[i];
- a[i] - a[lowindex];
- a[lowindex] = temp;
- }
- }
- int main()
- {
- int n = 0, m, i;
- student stud[25];
- if (!in)
- cout << "Error,file Input.txt doesn't open";
- else
- {
- in >> m;
- while (in.peek() != EOF)
- {
- in >> stud[n].fam;
- in >> stud[n].name;
- in >> stud[n].secondname;
- for (i = 0; i < 5; i++)
- {
- in >> stud[n].mark[i];
- }
- n++;
- }
- sort(stud, n);
- out << m << end;
- for (i = 0; i < n; i++)
- stud[i].print();
- }
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment