编辑代码

using System;

public class HelloWorld
{
    static void Main(string[] args)


        {

            int i = int.Parse(Console.ReadLine());

            string[] strings = new string[5000];

            

            int  s = Print(i,strings);

            Console.WriteLine(s);

            for (int o=0;o<s;o++)

               Console.WriteLine("{0}",strings[o]);

            Console.ReadKey();

          

        }

        static int Print( int v, string[] strings)

        {

            int[] ints = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

            int count = 0;

            do

            {

                for (int i = 1; i <=7; i++)

                {

                    for (int j = i + 1; j <= 8; j++)

                    {

                        int a = cvv(ints, 0, i);

                        int b = cvv(ints, i, j - i);

                        int c = cvv(ints, j, 9 - j);

                        

                            if (b % c == 0 && v == a + b / c)

                            {

                               strings[count++]=$"{v} = {a} + {b}/{c}";

                          

                            }

                        

                    }

                }

               

            } while (aff(ints)) ;

            return count;

            }

        static int cvv(int[] ints, int start, int cou)

        {

            int num = 0;

            for (int i = 0; i < cou; i++)

            {

                num = num * 10 + ints[start+i];

            }

            return num;

        }

        static bool aff(int[] ints)

        {

            int i = ints.Length - 2;

            while (i >= 0&& ints[i] >= ints[i+1]) i--;

            if (i <0) return false;

            int j = ints.Length - 1;

            while (j>i&&ints[i] <= ints[j]) j--;

            Swap(ints, i, j);

            Array.Reverse(ints,i+1,ints.Length-(i+1));

            return true;

        }

        static void Swap(int[] ints, int i, int j)

        {

            int temp = ints[i];

            ints[i] = ints[j];

            ints[j] = temp;

        }
}