You are viewing a single comment's thread. Return to all comments →
Hi, Can you tell me error in this C# code ? I am not able to figure out.
static void Main(String[] args) { int[] list =Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); Array.Sort(list); int[] First = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int[] Second = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int[] Third = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); int sum1; int sum2; int sum3; sum1 = sum2 = sum3 = 0; Dictionary<int, int> h1 = new Dictionary<int, int>(); Dictionary<int, int> h2 = new Dictionary<int, int>(); Dictionary<int, int> h3 = new Dictionary<int, int>(); for(int i=list[2]-1; i>=0;i--) { if(i < First.Length) { sum1 += First[i]; h1.Add(i, sum1); } if(i < Second.Length) { sum2 += Second[i]; h2.Add(i, sum2); } if(i < Third.Length) { sum3 += Third[i]; h3.Add(i, sum3); } } bool bls = false; foreach(KeyValuePair<int, int> li in h1) { if(h2.ContainsValue(li.Value) && h3.ContainsValue(li.Value)) { bls = true; Console.WriteLine(li.Value); break; } } if(!bls) { Console.WriteLine("0"); } }
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
Hi, Can you tell me error in this C# code ? I am not able to figure out.