Thursday, March 21, 2013

C#: Permutation two integer numbers


//Example: Write a program with type Console Application, enter two numbers a and b. Take two of these permutations. For example: a = 5, b = 7 => a = 7, b = 5.
namespace Example_Permutation{
    class Program{
        static void Main (){
            int a, b, temp;
            Console.Write ("Enter A:");
            a = int.Parse (Console.ReadLine ());
            Console.Write ("Enter B:");
            b = int.Parse (Console.ReadLine ());
            / / Use intermediate variable temp to store the swap value of a, b
            temp = a;
            a = b;
            b = temp;
            Console.WriteLine ("The value of a = {0}, b = {1}", a, b);
            Console.ReadLine ();
        }
    }
}

No comments:

Post a Comment