fork download
  1. #include<bits/stdc++.h>
  2. //if bits doesnt work,
  3. //try changing to #include<iostream>
  4. using namespace std;
  5.  
  6. int main(){
  7. int tc; cin >> tc;
  8. for (int i = 1; i <= tc; i++){
  9. int X1, Y1, X2, Y2;
  10. cin >> X1 >> Y1 >> X2 >> Y2;
  11.  
  12. if (X1 != X2 && Y1 != Y2){
  13. cout << abs(X1-X2) + abs(Y2-Y1) + 2 << endl;
  14. }
  15. else{
  16. cout << abs(X1-X2) + abs(Y2-Y1) << endl;
  17. }
  18. }
  19. }
  20.  
  21. /*
  22. If you are inputing with python,
  23. you can use something like this:
  24.  
  25. w = int(input())
  26.  
  27. for multiple variables in a line, you can do:
  28. x1, y1, x2, y2 = list(map(int, input().split(" ")))
  29.  
  30. */
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty