Advertisement
yahorrr

Untitled

Nov 24th, 2021
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. //#include <stdio>
  4.  
  5. using namespace std;
  6. void s_vb(sotrudnik* a, int n);
  7.  
  8.  
  9. struct sotrudnik
  10. {
  11.     char fio[40];
  12.     int tabelnomer;
  13.     int kolchasov;
  14.     double tarif;
  15. } banksystem[100];
  16.  
  17. int main()
  18. {
  19.     int n, i, j;
  20.     cout << "vvedite kol-vo sotrudnikov: ";
  21.     cin >> n;
  22.     for (i = 0; i < n; i++) {
  23.         cout << "Vvedite FIO: ";
  24.         cin >> banksystem[i].fio;
  25.         cout << "Vvedite tabelinii nomer: ";
  26.         cin >> banksystem[i].tabelnomer;
  27.         cout << "Vvedite kol-vo chasov: ";
  28.         cin >> banksystem[i].kolchasov;
  29.         cout << "Vvedite po4asovoi tarif: ";
  30.         cin >> banksystem[i].tarif;
  31.     }
  32.     s_vb(banksystem, n);
  33.     for (int i = 0; i < n; i++)
  34.     {
  35.         cout << banksystem[i].kolchasov << ' ';
  36.     }
  37.     system("pause");
  38. }
  39.  
  40. void s_vb(sotrudnik* a, int n)
  41. {
  42.     int imin, i, j, t;
  43.     for (i = 0; i < n - 1; i++) {
  44.         imin = i;
  45.         for (j = i + 1; j < n; j++)
  46.             if (a[imin].kolchasov > a[j].kolchasov) imin = j;
  47.         if (imin != i) {
  48.             t = a[imin].kolchasov;
  49.             a[imin].kolchasov = a[i].kolchasov;
  50.             a[i].kolchasov = t;
  51.         }
  52.     }
  53. }
  54.  
  55. //void s_qs(sotrudnik st*, int n)
  56. //{
  57. //    struct { int l; int r; }
  58. //    stack[20];
  59. //    int i, j, left, right, x, s = 0;
  60. //    sotrudnik  t;
  61. //
  62. //    stack[s].l = 0;
  63. //    stack[s].r = n - 1;
  64. //    while (s != -1) {
  65. //        left = stack[s].l;
  66. //        right = stack[s].r;
  67. //        s--;
  68. //        while (left < right) {
  69. //            i = left;
  70. //            j = right;
  71. //            x = st[(left + right) / 2].kolchasov;
  72. //            while (i <= j) {
  73. //                while (st[i].kolchasov < x) i++;
  74. //                while (st[j].kolchasov > x) j--;
  75. //                if (i <= j) {
  76. //                    t = st[i];
  77. //                    st[i] = st[j];
  78. //                    st[j] = t;
  79. //                    i++;
  80. //                    j--;
  81. //                }
  82. //            }
  83. //            if ((j - left) < (right - i)) {
  84. //                if (i < right) { s++;  stack[s].l = i;  stack[s].r = right; }
  85. //                right = j;
  86. //            }
  87. //            else {
  88. //                if (left < j) { s++;  stack[s].l = left;  stack[s].r = j; }
  89. //                left = i;
  90. //            }
  91. //        }
  92. //    }
  93. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement