static void Main(string[] args)
        {
            int a = 4, b = 5;
            Console.WriteLine("交换前:");
            Console.WriteLine("a=" + a);
            Console.WriteLine("b=" + b);
            SwapAB(ref a, ref b);
            Console.WriteLine("交换后:");
            Console.WriteLine("a=" + a);
            Console.WriteLine("b=" + b);
            Console.ReadLine();
        }

        private static void SwapAB(ref int a, ref int b)
        {
            a = a + b - (b = a);
        }

相关文章:

  • 2022-12-23
  • 2021-06-06
  • 2022-12-23
  • 2021-05-16
  • 2022-02-03
  • 2022-02-02
  • 2021-07-30
  • 2021-09-16
猜你喜欢
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案