Advertisement
myLoveOnlyForYou

Untitled

Mar 26th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <cmath>
  4. #include <string>
  5. #include <iomanip>
  6. #include <regex>
  7. #include <cstdlib>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12. freopen("input.txt", "r", stdin);
  13. freopen("output.txt", "w", stdout);
  14. int n; cin >> n;
  15. int a; double b; cin >> a >> b; cout << a << " " << b;
  16. double **w = new double*[n];
  17. double **pher = new double*[n];
  18. int *visited = new int[n];
  19. int ants[10];
  20. for (int i = 0; i < n; i++) {
  21. w[i] = new double[n];
  22. pher[i] = new double[n];
  23. visited[i] = 0;
  24. for (int j = 0; j < n; j++) {
  25. cin >> w[i][j];
  26. pher[i][j] = 1;
  27. }
  28. }
  29. double
  30. alpha = 1,
  31. beta = 1,
  32. best_path = 100000000;
  33.  
  34. for (int q = 0; q < 10; q++) {
  35. // int i = rand() % n;
  36. int i = 0;
  37. visited[i] = 1;
  38. double *Ps = new double[n];
  39. for (int k = 0; k < n; k++)
  40. Ps[k] = 0;
  41. for (int m = 0; m < 10; m++) {
  42. double znam = 0;
  43. for (int j = 0; j < n; j++) {
  44. if (j != i && w[i][j] != 0) {
  45. znam += pher[i][j] / w[i][j];
  46. }
  47. }
  48.  
  49. for (int j = 0; j < n; j++) {
  50. if (j != i && w[i][j] != 0) {
  51. Ps[j] = (pher[i][j] * 1 / w[i][j]) / znam;
  52. cout << "1 -> " << j + 1 << ": " << Ps[j] << endl;
  53. }
  54. }
  55. }
  56. }
  57.  
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement