fork download
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <windows.h>
  4. #include <functional>
  5. using namespace std;
  6.  
  7.  
  8. struct Worker{
  9. char name[20];
  10. int age;
  11. int exp;
  12. };
  13.  
  14.  
  15. void Input(Worker* arrWithDigits[], int size ){
  16.  
  17. for (int i = 0; i < size; i++){
  18. for (int j = 0; j < size; j++){
  19. cout << "Фамилия: ";
  20. cin.getline(arrWithDigits[i][j].name, 20);
  21. cout << "Год рождения: ";
  22. cin >> arrWithDigits[i][j].age;
  23. cout << "Опыт работы: ";
  24. cin >> arrWithDigits[i][j].exp;
  25. cin.get();
  26. }
  27. }
  28.  
  29. }
  30.  
  31. void SortShell(Worker* arrWithDigits[], int size)
  32.  
  33. // Вот эта функция - полная хуйня
  34. // Сортирует НЕПРАВИЛЬНО, во-первых сортирует не столбцы, а строки, во-вторых пропускает первую строку
  35. // ну и в третьих - swap НЕ РАБОТАЕТ. С чем это связанно понимаю: менять нужно полностью структуры
  36. // то что написано тут меняет только года рождения, в этом и косяк.
  37. // Отсортировать столбцы никак у меня не выходит, чтобы я не делал, все хуйня, а поменять структуры местами
  38. // тем более. вот и прошу у тебя помощи, знающий анон.
  39.  
  40.  
  41. {
  42. for (int gap = size/2; gap>0; gap/=2)
  43. for (int i=gap; i<size; i++)
  44. for (int j=i-gap; j>=0 && arrWithDigits[i][j].age > arrWithDigits[i][j+gap].age; j-=gap)
  45. swap(arrWithDigits[i][j].age, arrWithDigits[i][j+gap].age);
  46. }
  47.  
  48.  
  49.  
  50.  
  51. void Output(Worker* arrWithDigits[], int size){
  52.  
  53. for (int i = 0; i < size; i++){
  54. for (int j = 0; j < size; j++){
  55. cout << arrWithDigits[i][j].name << ", "<< arrWithDigits[i][j].age << ", "<< arrWithDigits[i][j].exp << '\t'<<" | ";
  56. }
  57. cout << endl;
  58. }
  59. cout << endl << endl;
  60. }
  61.  
  62.  
  63. int main()
  64. {
  65. SetConsoleCP(1251);
  66. SetConsoleOutputCP(1251);
  67.  
  68. int size;
  69.  
  70. cout << "Введите размер матрицы: ";
  71. cin >> size;
  72. cin.get();
  73.  
  74. Worker** arrWithDigits = new Worker* [size];
  75. for (int i = 0; i < size; i++){
  76. arrWithDigits[i] = new Worker[size];
  77. }
  78.  
  79. cout << endl << endl;
  80. cout << "Введите данные о " << size*size << " сотрудниках" << endl;
  81. Input(arrWithDigits, size);
  82.  
  83. system("cls");
  84. cout << "Матрица (Фамилия, год рождения, стаж работы)" << endl;
  85. Output(arrWithDigits, size);
  86.  
  87. cout << "Матрица (Фамилия, год рождения, стаж работы)" << endl;
  88. SortShell(arrWithDigits, size);
  89. Output(arrWithDigits, size);
  90.  
  91. return 0;
  92. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:22: fatal error: windows.h: No such file or directory
compilation terminated.
stdout
Standard output is empty