fork(1) download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <string>
  5. #include <vector>
  6. using namespace std;
  7.  
  8. class KURSA4
  9. {
  10. private:
  11. struct worker
  12. {
  13. int worked_together;
  14. int psy_compatible;
  15. };
  16. int n;
  17. vector<vector<worker>> ptr;
  18. vector<string> name;
  19.  
  20.  
  21. public:
  22. void print_matrix() //отладочная функция, не забудь удалить,
  23. {
  24. for (int i = 0; i < n; i++)
  25. {
  26. cout << name[i];
  27.  
  28. for (int j = 0; j < n; j++)
  29. {
  30. cout << ptr[i][j].worked_together;
  31. }
  32. cout << endl;
  33. }
  34. }
  35. KURSA4()
  36. {
  37. FILE* file = stdin; //fopen("list.txt", "rt");
  38. fscanf(file, "%d", &n);
  39. while(fgetc(file) != '\n');
  40.  
  41. ptr.resize(n);
  42. name.resize(n);
  43. //ptr = new worker*[n];
  44. //name = new string[n];
  45.  
  46. for (int i = 0; i < n; i++)
  47. {
  48. ptr[i].resize(n);
  49. }
  50.  
  51. for (int i = 0; i < n; i++)
  52. {
  53. char temp[50];
  54. fscanf(file, "%[^,]", temp);
  55. name[i] = temp;
  56.  
  57. for (int j = i + 1; j < n ; j++)
  58. {
  59. worker temp;
  60. fscanf(file, ",%d,%d", &temp.worked_together, &temp.psy_compatible);
  61. ptr[i][j] = temp;
  62. ptr[j][i] = temp;
  63. }
  64. while(fgetc(file) != '\n');
  65. }
  66. }
  67. };
  68.  
  69. int main()
  70. {
  71. setlocale(LC_ALL, "RUS");
  72. KURSA4 a2;
  73. a2.print_matrix();
  74. system("PAUSE");
  75. }
Success #stdin #stdout #stderr 0s 3420KB
stdin
4  
Савельев Самсон Алексеевич,0,1,0,1,0,0  
Константинов Василий Владимирович,0,1,0,0  
Соколова Марина Михайловна,0,1  
Покровский Наум Юрьевич,
stdout
Савельев Самсон Алексеевич0000
Константинов Василий Владимирович0000
Соколова Марина Михайловна0000
Покровский Наум Юрьевич0000
stderr
sh: 1: PAUSE: not found