Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<string>
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream in("in.txt");
- ofstream out("out.txt");
- struct unic {
- string numgr, fam, im, ot, year;
- int f, ff, fff, ffff;
- void print();
- };
- void unic::print() {
- out << numgr << ' ' << fam << ' ' << im << ' ' << ot << ' ' << year << ' ' << f << ' ' << ff << ' ' << fff << ' ' << ffff << endl;
- }
- int main() {
- setlocale(LC_ALL, "russian");
- unic swap,a[5];
- for (int i = 0; i < 5; i++) {
- in >>a[i].numgr>>a[i].fam >> a[i].im >> a[i].ot>> a[i].year >> a[i].f >> a[i].ff>>a[i].fff>>a[i].ffff;
- }
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 4; j++) {
- if (a[j].fam > a[j + 1].fam) {
- swap = a[j];
- a[j] = a[j + 1];
- a[j + 1] = swap;
- }
- }
- }
- out << "По фамилии:" << endl;
- for (int i = 0; i < 5; i++) {
- a[i].print();
- }
- for (int i = 0; i < 5; i++) {
- for (int j = 0; j < 4; j++) {
- if (a[j].year < a[j + 1].year) {
- swap = a[j];
- a[j] = a[j + 1];
- a[j + 1] = swap;
- }
- }
- }
- out << "По году рождения:" << endl;
- for (int i = 0; i < 5; i++) {
- a[i].print();
- }
- system("pause");
- in.close();
- out.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement