【发布时间】:2016-03-03 22:34:35
【问题描述】:
我需要编写一个程序,它在数组 arr[n] 中找到递增元素的最大序列。不必连续放置元素。例如:{9, 6, 2, 7, 4, 7, 6, 5, 8, 4} -> {2, 4, 6, 8}。 我有一些使用 2 个嵌套循环和一个附加数组的准则。 到目前为止,我知道如何使用 if 语句、循环和小数组。 有什么建议请...? 到目前为止,这是我的开始(我走上正轨了吗?):
Console.Write("Elements in array: ");
int n = int.Parse(Console.ReadLine());
int[] arr = new int[n];
int[] result;
for (int index = 0; index < arr.Length; index++)
{
Console.Write("Array [{0}] = ", index);
arr[index] = int.Parse(Console.ReadLine());
}
for (int indexOut = 0; indexOut < n; indexOut++)
{
for (int indexIn = 1; indexIn < n; indexIn++)
{
}
}
【问题讨论】: