C#-练习题
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 }
结果