Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int infinit=1000000, n, c[102][102], d[102], s[102], t[102],m;
- ifstream in("dijkstra.in");
- ofstream out("dijkstra.out");
- void citire()
- { int x,y,cs;
- cin>>n>>m;
- for(int i=1;i<=m;i++)
- { cin>>x>>y>>cs;
- c[x][y]=c[y][x]=cs;
- }
- }
- int media()
- {int vf=0,minim=12312;
- for(int i=1;i<=n;i++)
- {int ma=0,ct=0;
- for(int j=1;j<=n;j++)
- {
- if(c[i][j])
- {ma+=c[i][j];
- ct++;}
- }
- if((ma/ct)<minim)
- {
- vf=i;
- minim=(ma/ct);
- }
- }
- return vf;
- }
- int main()
- {citire();
- cout<<media();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement