Created
November 7, 2022 09:50
-
-
Save kid-cavaquinho/a5772b820fcfc296e6cc889ffa35fc05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The Manhattan distance between two points is the sum of absolute difference of the coordinates. | |
| static int Resolve(int M, int N, int X1, int Y1, int X2, int Y2) | |
| { | |
| return Math.Abs(X2 - X1) + Math.Abs(Y2 - Y1); | |
| } | |
| public static void Main() | |
| { | |
| // Define size of 2-D array | |
| int M = 5, N = 5; | |
| // First point | |
| int X1 = 1, Y1 = 2; | |
| // Second point | |
| int X2 = 3, Y2 = 3; | |
| Console.WriteLine(Resolve(M, N, X1, Y1, X2, Y2)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment