Advertisement
Guest User

Untitled

a guest
May 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. 4
  2. Савельев Самсон Алексеевич,0,1,0,1,0,0
  3. Константинов Василий Владимирович 0,1,0,0
  4. Соколова Марина Михайловна,0,1
  5. Покровский Наум Юрьевич,
  6.  
  7. #define _CRT_SECURE_NO_WARNINGS
  8. #include iostream
  9. #include cstdio
  10. #include string
  11. using namespace std;
  12.  
  13. class KURSA4
  14. {
  15. private:
  16. struct worker
  17. {
  18. int worked_together;
  19. int psy_compatible;
  20. };
  21. int n;
  22. worker** ptr;
  23. string* name;
  24.  
  25.  
  26. public:
  27. void print_matrix() //отладочная функция, не забудь удалить,
  28. {
  29. for (int i = 0; i < n; i++)
  30. {
  31. cout << name[i];
  32. }
  33.  
  34. for (int i = 0; i < n; i++)
  35. for (int j = 0; j < n; j++)
  36. {
  37. cout << ptr[i][j].worked_together;
  38. }
  39. }
  40. KURSA4()
  41. {
  42. FILE* file = fopen("H:/KURS/list.txt", "rt");
  43. fscanf(file, "%d", &n);
  44. ptr = new worker*[n];
  45. name = new string[n];
  46.  
  47. for (int i = 0; i < n; i++)
  48. {
  49. ptr[i] = new worker[n];
  50. }
  51.  
  52. for (int i = 0; i < n; i++)
  53. {
  54. char temp[50];
  55. fscanf(file, "%[^,]", temp);
  56. name[i] = (const char*)temp;
  57.  
  58. for (int j = i + 1; j < n ; j++)
  59. {
  60. worker temp;
  61. fscanf(file, "%d,%d", &temp.worked_together, &temp.psy_compatible);
  62. ptr[i][j].worked_together = temp.worked_together;
  63. ptr[j][i].worked_together = temp.worked_together;
  64. ptr[i][j].psy_compatible = temp.psy_compatible;
  65. ptr[j][i].psy_compatible = temp.psy_compatible;
  66. }
  67. }
  68. }
  69. };
  70.  
  71. void main()
  72. {
  73. setlocale(LC_ALL, "RUS");
  74. KURSA4 a2;
  75. a2.print_matrix();
  76. system("PAUSE");
  77. }
  78.  
  79. Савельев Самсон Алексеевич
  80. Савельев Самсон Алексеевич
  81. Савельев Самсон Алексеевич
  82. Савельев Самсон Алексеевич-842150451-858993460-858993460-858993460-858993460-842
  83. 150451-858993460-858993460-858993460-858993460-842150451-858993460-858993460-858
  84. 993460-858993460-842150451Для продолжения нажмите любую клавишу . . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement