Application Development

Software technique, Skills & Applications

Match September 30, 2008

Filed under: Uncategorized — meetme @ 12:59 pm

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string[] stdA = { “1″, “2″, “3″, “4″, “2″ };
            string[] optA = { “2″, “2″, “4″, “5″, “4″ };
            int[] stdU = { 0, 0, 0, 0, 0 };
            int[] optU = { 0, 0, 0, 0, 0 };

            int B = 0;
            int W = 0;

            for(int i=0;i < 5;i++)
            {
                if (stdA[i] == optA[i])
                {
                    B += 1;
                    stdU[i] = 1;
                    optU[i] = 1;
                }

                for (int j = 0; j < 5; j++)
                {
                    if (i != j)
                    {
                        if (stdA[i] == optA[j] && stdU[i] == 0 && optU[j] == 0)
                        {
                             W += 1;
                             stdU[i] = 1;
                             optU[j] = 1;
                         }
                    }
                }
            }

            Console.Write(“B=”+B.ToString() + “  W=”+W.ToString() );
            Console.Read();
        }
    }
}

 

Leave a Reply