Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int n,m,b[100][100],gama[100],omega[100],v[100];
  7.  
  8. int main()
  9. {
  10. ifstream f("date.in");
  11. f >> n >> m;
  12. int x,y;
  13. for(int j=1;j<=m;j++)
  14. {
  15. f >> x >> y;
  16. b[x][j]=1;
  17. b[y][j]=-1;
  18. }
  19. int k1=1,k2=1;
  20. for(int i=1;i<=n;i++)
  21. {
  22. //cout <<"gama- pentru nodul " << i << ": ";
  23. for(int j=1;j<=m;j++){
  24. if(b[i][j]==-1)
  25. for(int k=1;k<=n;k++)
  26. if(b[k][j]==1)
  27. omega[k2++]=k;
  28. }
  29. //cout << endl;
  30. }
  31. //cout << endl;
  32. for(int i=1;i<=n;i++)
  33. {
  34. //cout <<"omega+ pentru nodul " << i << ": ";
  35. for(int j=1;j<=m;j++){
  36. if(b[i][j]==1)
  37. for(int k=1;k<=n;k++)
  38. if(b[k][j]==-1)
  39. gama[k1++]=k;
  40. }
  41. }
  42. int k3=1;
  43. for(int i=1;i<k1;i++)
  44. for(int j=1;j<k2;j++)
  45. if(gama[i]==omega[j])
  46. {
  47. v[k3++]=gama[i];
  48. omega[i]=0;
  49. break;
  50. }
  51. return 0;
  52. }
  53. #include <iostream>
  54. #include <fstream>
  55.  
  56. using namespace std;
  57.  
  58. int n,m,b[100][100],gama[100],omega[100],v[100];
  59.  
  60. int main()
  61. {
  62. ifstream f("date.in");
  63. f >> n >> m;
  64. int x,y;
  65. for(int j=1;j<=m;j++)
  66. {
  67. f >> x >> y;
  68. b[x][j]=1;
  69. b[y][j]=-1;
  70. }
  71. int k1=1,k2=1;
  72. for(int i=1;i<=n;i++)
  73. {
  74. //cout <<"gama- pentru nodul " << i << ": ";
  75. for(int j=1;j<=m;j++){
  76. if(b[i][j]==-1)
  77. for(int k=1;k<=n;k++)
  78. if(b[k][j]==1)
  79. omega[k2++]=k;
  80. }
  81. //cout << endl;
  82. }
  83. //cout << endl;
  84. for(int i=1;i<=n;i++)
  85. {
  86. //cout <<"omega+ pentru nodul " << i << ": ";
  87. for(int j=1;j<=m;j++){
  88. if(b[i][j]==1)
  89. for(int k=1;k<=n;k++)
  90. if(b[k][j]==-1)
  91. gama[k1++]=k;
  92. }
  93. }
  94. int k3=1;
  95. for(int i=1;i<k1;i++)
  96. for(int j=1;j<k2;j++)
  97. if(gama[i]==omega[j])
  98. {
  99. v[k3++]=gama[i];
  100. omega[i]=0;
  101. break;
  102. }
  103. return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement