Skip to content

Instantly share code, notes, and snippets.

@iwhcoj
Created May 3, 2010 16:18
Show Gist options
  • Save iwhcoj/388264 to your computer and use it in GitHub Desktop.
Save iwhcoj/388264 to your computer and use it in GitHub Desktop.
//joanna wilbur
import java.util.*;
public class proj6q8
{
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
int [] UsersArray = new int[100];
int ArraySize;
System.out.println("How many integers are in the sequence?");
ArraySize=input.nextInt();
System.out.println("Enter an array and stop using -999.");
for (int i=0; i<ArraySize; i++)
{
UsersArray [i]=input.nextInt();
if (UsersArray [i]== -999)
break;
}//end for loop
FindSubsequence(ArraySize, UsersArray);
}//end main
public static int FindSubsequence(int ArraySize, int UsersArray [])
{
Scanner input = new Scanner(System.in);
int max=0, maxStart, maxEnd;
for (int x=0; x<ArraySize; x++)
{
maxStart=x;
for (int j=0;UsersArray[x]<UsersArray[j]; j++)
{
maxEnd=j;
}
for (int i=maxStart; i==maxEnd; i++)
System.out.println("Longest sequence is " + UsersArray[i]);
}
return max;
}// end FindSubsequence
}//end class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment