Advertisement
Guest User

clim

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