Write a program that takes two comma - separated list of integers as input.for each integer N in the first list. The program needs to find count of its occurrence called C in the second list. The program should print the N-C for each integer



Note This Program Is written in C#

 class Program
    {
        static void Main(string[] args)
        {
            string list1, list2;
            list1 = Console.ReadLine().ToString();
            list2 = Console.ReadLine().ToString();
            string[] array1 = list1.Split(',');
            string[] array2 = list2.Split(',');
            for (int i = 0; i < array1.Length; i++)
            {
                string value = array1[i];
                int count = 0;
                for (int j = 0; j < array2.Length; j++)
                {
                    if (value == array2[j])
                    {
                        count++;
                    }
                }
                Console.WriteLine(value + "-" + count);
            }
        }
    }

Output:-

If you have More Questions Please Write in Comments

Thank you for sharing Your Knowledge with others who need It.-Team LetML

Post a Comment

Copyright © LetML. Blogger Templates Designed by OddThemes