Advertisement
meriellez

Untitled

May 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. long a[101][101], sum = 0, res[4] = {0, 1, 2}, k = -1;
  5. long minimal;
  6. int main() {
  7. // your code goes here
  8. long l, i, j, n;
  9. cin >>n;
  10. for(i = 0; i < n; i++){
  11. for(j = 0; j < n; j++){
  12. cin >>a[i][j];
  13. }
  14. }
  15. minimal = a[0][1]+a[1][2]+a[2][0];
  16. for(i = 0; i < n; i++){
  17. for(j = 0; j < n; j++){
  18. for(l = 0; l < n; l++){
  19. sum = a[i][j] + a[i][l] + a[j][l];
  20. if(i != j && j != l && l != i && sum < minimal){
  21. minimal = sum;
  22. res[0] = i;
  23. res[1] = j;
  24. res[2] = l;
  25. }
  26. }
  27. }
  28. }
  29. // <<endl;
  30. cout <<res[0] + 1 <<' ' <<res[1] + 1 <<' ' <<res[2] + 1;
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement