Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define N 101
- using namespace std;
- int n, m, a[N][N];
- void Read()
- {
- int i, x, y, c;
- cin >> n >> m;
- for (i = 1; i <= m; i++)
- {
- cin >> x >> y >> c;
- a[x][y] = a[y][x] = c;
- }
- }
- int F(int x)
- {
- double sum;
- int i, k;
- sum = 0;
- k = 0;
- for (i = 1; i <= n; i++)
- if (a[x][i] != 0)
- {
- sum = sum + a[x][i];
- k++;
- }
- sum = sum / k;
- return sum;
- }
- int main()
- {
- double Min;
- Min = 1e9;
- int i, k;
- Read();
- for (i = 1; i <= n; i++)
- if (F(i) < Min)
- {
- Min = F(i);
- k = i;
- }
- cout << k;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement