1、输入两个数,将两个数交换后输出

 1 using System;
 2 
 3 namespace ExchangeTwoNumbers
 4 {
 5     class ExchangeTwoNumbers
 6     {
 7         static void Main(string[] args)
 8         {
 9             Console.WriteLine("Enter two integers and end with the enter key");
10             Console.Write("Please input a:");
11             int a = Convert.ToInt32(Console.ReadLine());
12             Console.Write("Please input b:");
13             int b = Convert.ToInt32(Console.ReadLine());
14 
15             a = a - b;
16             b = a + b;
17             a = b - a;
18 
19             Console.WriteLine("a is:{0}", a);
20             Console.WriteLine("b is:{0}", b);
21             Console.ReadKey();
22         }
23     }
24 }

结果

C#-练习题

相关文章:

  • 2022-12-23
  • 2022-01-29
  • 2021-12-06
  • 2021-11-13
  • 2021-10-14
  • 2022-01-04
  • 2022-02-15
  • 2022-02-23
猜你喜欢
  • 2021-04-16
  • 2021-04-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-02-25
  • 2022-12-23
相关资源
相似解决方案