Question: This is the problem that I am trying to solve and this is my code: using System; using System.IO; namespace Lazy_Fox { class Program {


This is the problem that I am trying to solve and this is my code:
using System; using System.IO;
namespace Lazy_Fox { class Program { static void Main(string[] args) { Console.WriteLine("Enter the number of neighbours: "); int N = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the coordinates for all the neighbours: ");
int[] x = new int[N]; int[] y = new int[N];
for(int i=0; i double totalTreats = calculations(0, 0, x, y, N, 9999999); Console.WriteLine(); Console.WriteLine("The total number of treats that the fox gathers is: "+totalTreats); } static int calculations(int currentX, int currentY, int[] x, int[] y, int N, double lastDistance) { if (lastDistance == 0) { return 1; } double maxDistance = 0; double distance; int index = 0; for (int i = 0; i if (distance maxDistance) { maxDistance = distance; index = i; } } } if(maxDistance != 0) { return (1 + calculations(x[index], y[index], x, y, N, maxDistance)); } else { return 1; } } } } I am not sure what I am doing wrong but when i put in the sample input I am getting the right output but when i put in the input that my teacher has asked which is: 10 75 1 55 70 53 92 37 46 47 6 49 86 80 14 79 50 0 71 13 27 The output I am getting out of this is 12...when the right output for this input is 17. I am not sure what I am doing wrong here...I would really appreciate if someone could help me out here...THANK YOU NOTE: CODE USING C#
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
