Advertisement
Guest User

123

a guest
Jan 23rd, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, m, a[101][101];
  6.  
  7. void Citire()
  8. {
  9. int i, x, y, c;
  10. cin >> n >> m;
  11. for (i = 1; i <= m; i++)
  12. {
  13. cin >> x >> y >> c;
  14. a[x][y] = a[y][x] = c;
  15. }
  16. }
  17.  
  18. int FCT(int x)
  19. {
  20. double p;
  21. int i, k;
  22. p = 0;
  23. k = 0;
  24. for (i = 1; i <= n; i++)
  25. if (a[x][i] != 0){p = p + a[x][i]; k++;}
  26. p = p / k;
  27. return p;
  28. }
  29.  
  30. int main()
  31. {
  32. double minim;
  33. minim = 1000000000000;
  34. int i, k;
  35. Citire();
  36. for (i = 1; i <= n; i++)
  37. if (FCT(i) < minim) {minim = FCT(i); k = i;}
  38. cout << k;
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement