嗨,我是 c# 编程的新手,我正在做一个将输入多少输入的活动,它将查看插入的数字。现在我只有一个问题,如何才能只查看最后插入的数字,这是我的代码:
Console.Write("Enter How Many Inputs: ");
int num1 = int.Parse(Console.ReadLine());
int[] arr = new int[num1];
for (int i = 0; i < num1; i++) {
Console.Write("Input Value #" + (i + 1) + ":");
arr[i] = int.Parse(Console.ReadLine());
}
Console.Write("The Numbers inserted are: ");
for (int x = 0; x < arr.Length; x++) {
Console.Write(" " + arr[x]);
}
Console.Write("The Last Number Inserted is: ");
(???)
Sample Output:
Enter How Many Inputs: 3
Value #1: 80
Value #2: 83
Value #3: 50
The Numbers inserted are: 80 83 50
The Last Number inserted is: 50
我不知道我将使用什么循环来查看最后插入的数字。谢谢!