我正在尝试找到数组中增长数字最长的段。
ex:array - {4.5 9.2 3 5 6 7 4.3 -2 8 8 8 3 3}
输出 - {3 5 6 7}
这是我编写的代码,我知道它非常糟糕,但我是如何写的,我会改进它。
如果您需要更多信息,请告诉我,我会在回来后发布。
System.out.print("How many numbers will you enter? >>> ");
int numbers = console.nextInt();
console.nextLine();
double arrayList[] = new double[numbers];
System.out.print("Type in numbers with spaces in between >>>");
for(int i = 0; i < arrayList.length; i++)
{
arrayList[i] = console.nextDouble();
}
console.nextLine();
double grand = 0, x;
int l = 0, inOut = 1;
int count = 0, count2 = 0;
double sum[] = new double[inOut];
double fnum[] = new double[inOut];
for(int i = 0; i < arrayList.length - 1; i++)
{
x = arrayList[i];
grand = arrayList[i + 1];
if(x < grand)
{
sum[l] = x;
l++;
inOut++;
count++;
}
else
{
if(count2 < count)
{
for(int k = 0; k < inOut; k++)
{
}
}
}
}