Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int infinit=1000000, n, c[102][102], d[102], s[102], t[102],m;
  5. ifstream in("dijkstra.in");
  6. ofstream out("dijkstra.out");
  7. void citire()
  8. { int x,y,cs;
  9. cin>>n>>m;
  10.  
  11. for(int i=1;i<=m;i++)
  12. { cin>>x>>y>>cs;
  13. c[x][y]=c[y][x]=cs;
  14. }
  15.  
  16. }
  17.  
  18. int media()
  19. {int vf=0,minim=12312;
  20. for(int i=1;i<=n;i++)
  21. {int ma=0,ct=0;
  22. for(int j=1;j<=n;j++)
  23. {
  24. if(c[i][j])
  25. {ma+=c[i][j];
  26. ct++;}
  27.  
  28.  
  29. }
  30.  
  31. if((ma/ct)<minim)
  32. {
  33. vf=i;
  34. minim=(ma/ct);
  35.  
  36. }
  37. }
  38. return vf;
  39.  
  40. }
  41.  
  42. int main()
  43. {citire();
  44.  
  45. cout<<media();
  46.  
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement