You are viewing a single comment's thread. Return to all comments →
My C# Version:
int n = Convert.ToInt32(Console.ReadLine()); string[] arr_temp = Console.ReadLine().Split(' '); int[] arr = Array.ConvertAll(arr_temp, Int32.Parse); int[] count = new int[] { 0, 0, 0 }; decimal[] fraction = new decimal[] { 0, 0, 0 }; foreach (int num in arr) { if (num == 0) count[2]++; else if (num > 0) count[0]++; else count[1]++; } for(int idx = 0; idx < fraction.Length; idx++) { fraction[idx] = (decimal)count[idx] / (decimal)arr.Count(); } foreach(decimal num in fraction) { Console.WriteLine(string.Format("{0:N6}", num)); }
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
My C# Version: