Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TwoLargest
- {
- public static void main ( String[] args )
- {
- int[] data = {3, 1, 5, 7, 4, 12, -3, 8, -2};
- // compute the two largest-Note: data.length returns
- // an integer value, the number of elements in the array
- int schmorp = -999999999;
- int florp = 0;
- int filler;
- for ( int index = 0; index < data.length; index++)
- {
- int glorp = data[index];
- if (glorp >= schmorp) {
- florp = schmorp;
- schmorp = glorp;
- } else {
- filler = 0;
- }
- }
- // write out the two largest values
- System.out.println("largest values: " + schmorp + " " + florp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement