How to print all combination of 3 different digits in C#

1 Answer

0 votes
using System;
  
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 1, b = 7, c = 5;
  
            Console.WriteLine("{0} {1} {2}", a, b, c);
            Console.WriteLine("{0} {1} {2}", a, c, b);
            Console.WriteLine("{0} {1} {2}", b, a, c);
            Console.WriteLine("{0} {1} {2}", b, c, a);            
            Console.WriteLine("{0} {1} {2}", c, a, b);
            Console.WriteLine("{0} {1} {2}", c, b, a);
        }
    }
}
 
 
 
/*
run:
 
1 7 5
1 5 7
7 1 5
7 5 1
5 1 7
5 7 1
 
*/


answered Apr 9, 2014 by avibootz
edited Sep 29, 2021 by avibootz
...