Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct sotrudnik
- {
- char fio[40];
- int tabelnomer;
- int kolchasov;
- double tarif;
- } banksystem[100];
- void s_vb(sotrudnik* sotrudnik, int n);
- void s_qs(sotrudnik* st, int n);
- void showSotrudnik(sotrudnik* st, int n);
- int main()
- {
- int n;
- cout << "vvedite kol-vo sotrudnikov: ";
- cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Vvedite FIO: ";
- cin >> banksystem[i].fio;
- cout << "Vvedite tabelinii nomer: ";
- cin >> banksystem[i].tabelnomer;
- cout << "Vvedite kol-vo chasov: ";
- cin >> banksystem[i].kolchasov;
- cout << "Vvedite po4asovoi tarif: ";
- cin >> banksystem[i].tarif;
- cout << endl;
- }
- s_qs(banksystem, n);
- showSotrudnik(banksystem, n);
- }
- void s_vb(sotrudnik* sotrudnik, int n)
- {
- int imin, t;
- for (int i = 0; i < n - 1; i++) {
- imin = i;
- for (int j = i + 1; j < n; j++)
- if (sotrudnik[imin].kolchasov > sotrudnik[j].kolchasov) imin = j;
- if (imin != i) {
- t = sotrudnik[imin].kolchasov;
- sotrudnik[imin].kolchasov = sotrudnik[i].kolchasov;
- sotrudnik[i].kolchasov = t;
- }
- }
- }
- void s_qs(sotrudnik* st, int n)
- {
- struct { int l; int r; }
- stack[20];
- int i, j, left, right, x, s = 0;
- sotrudnik t;
- stack[s].l = 0;
- stack[s].r = n - 1;
- while (s != -1) {
- left = stack[s].l;
- right = stack[s].r;
- s--;
- while (left < right) {
- i = left;
- j = right;
- x = st[(left + right) / 2].kolchasov;
- while (i <= j) {
- while (st[i].kolchasov < x) i++;
- while (st[j].kolchasov > x) j--;
- if (i <= j) {
- t = st[i];
- st[i] = st[j];
- st[j] = t;
- i++;
- j--;
- }
- }
- if ((j - left) < (right - i)) {
- if (i < right) { s++; stack[s].l = i; stack[s].r = right; }
- right = j;
- }
- else {
- if (left < j) { s++; stack[s].l = left; stack[s].r = j; }
- left = i;
- }
- }
- }
- }
- void showSotrudnik(sotrudnik* st, int n)
- {
- for (int i = 0; i < n; i++)
- {
- cout << "kolichestvo chasov - " << banksystem[i].kolchasov << ' ' << banksystem[i].fio << ' ' << banksystem[i].tabelnomer << ' ' << banksystem[i].tarif << endl;
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement