Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. int arg, var, i, j;
  2.  
  3. cin >> arg;
  4.  
  5. int arr[arg][arg];
  6.  
  7. for (i = 0; i < arg; i++)
  8. {
  9. for(j = 0; j < arg; j++)
  10. {
  11. cin >> var;
  12. arr[i][j] = var;
  13. }
  14. }
  15.  
  16.  
  17. for(int pivot = 0; pivot < arg; pivot++)
  18. {
  19. for(i = 0; i < arg; i++)
  20. {
  21. for(j = 0; j < arg; j++)
  22. {
  23. if((arr[i][j] > (arr[i][pivot] + arr[pivot][j])) && ((arr[i][pivot] != -1) && arr[pivot][j] != -1))
  24. {
  25. arr[i][j] = (arr[i][pivot] + arr[pivot][j]);
  26. arr[j][i] = (arr[i][pivot] + arr[pivot][j]);
  27. }
  28. }
  29. }
  30. }
  31.  
  32. floyd>
  33. * * * Program successfully started and correct prompt received.
  34.  
  35. floyd 2 0 14 14 0
  36. 0 14 14 0
  37. floyd> PASS : Input "floyd 2 0 14 14 0" produced output "0 14 14 0".
  38.  
  39. floyd 3 0 85 85 85 0 26 85 26 0
  40. 0 85 85 85 0 26 85 26 0
  41. floyd> PASS : Input "floyd 3 0 85 85 85 0 26 85 26 0" produced output "0 85 85 85 0 26 85 26 0".
  42.  
  43. floyd 3 0 34 7 34 0 -1 7 -1 0
  44. 0 34 7 34 0 -1 7 -1 0
  45. floyd> FAIL : Input "floyd 3 0 34 7 34 0 -1 7 -1 0" did not produce output "0 34 7 34 0 41 7 41 0".
  46.  
  47. floyd 4 0 -1 27 98 -1 0 41 74 27 41 0 41 98 74 41 0
  48. 0 -1 27 68 -1 0 41 74 27 41 0 41 68 74 41 0
  49. floyd> FAIL : Input "floyd 4 0 -1 27 98 -1 0 41 74 27 41 0 41 98 74 41 0" did not produce output "0 68 27 68 68 0 41 74 27 41 0 41 68 74 41 0".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement