Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct Tworker {
- int bonus;
- string name, otdel;
- void print(){
- cout << name << " (" << otdel << "): " << bonus << endl;
- }
- };
- int main()
- {
- int n;
- bool change = true;
- Tworker a[100];
- ifstream f1("workers.txt");
- f1 >> n;
- cout << n << " Rec." << endl;
- for(int i = 0; i < n; i++)
- f1 >> a[i].name >> a[i].otdel >> a[i].bonus;
- while(change){
- change = false;
- for(int i = 0; i < n-1; i++)
- if (a[i].name > a[i+1].name){
- swap(a[i], a[i+1]);
- change = true;
- }
- }
- change = true;
- while(change){
- change = false;
- for(int i = 0; i < n-1; i++)
- if (a[i].otdel > a[i+1].otdel){
- swap(a[i], a[i+1]);
- change = true;
- }
- }
- for(int i = 0; i < n; i++) {
- cout << i << " ";
- a[i].print();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement