English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

public class arrai {
public void thousandRandomInts(int lowerBound, int upperBound) {
int range = upperBound - lowerBound;
int[] a;
a = new int[1000];
for (int i = 0; i < a.length; i++) {
a[i] = lowerBound + ((int) (Math.random() * 1001));
}
}
}

2007-02-01 04:03:06 · 4 answers · asked by funni_stuff101 1 in Computers & Internet Programming & Design

just a lil project i been workin on to improve my programming skills

2007-02-01 04:03:45 · update #1

4 answers

.public class arrai {
public void thousandRandomInts(int lowerBound, int upperBound) {
int range = upperBound - lowerBound;
int[] a;
a = new int[1000];
for (int i = 0; i < a.length; i++) {
a[i] = lowerBound + ((int) (Math.random() * 1001));
}
}
}

2007-02-01 04:06:36 · answer #1 · answered by Anonymous · 0 0

The pseudo code would be something like this for bubble sort.

function bubble_sort(list L, number listsize)
loop
has_swapped := 0 //reset flag
for number i from 1 to (listsize - 1)
if L[i] > L[i + 1] //if they are in the wrong order
swap(L[i], L[i + 1]) //exchange them
has_swapped := 1 //we have swapped at least once, list may not be sorted yet
endif
endfor
//if no swaps were made during this pass, the list has been sorted
if has_swapped = 0
exit
endif
endloop
endfunction

I would not like to do your homework probably you can look at this article for bubble sort http://en.wikipedia.org/wiki/Bubble_sort
and you can find other sorting algorithm at http://en.wikipedia.org/wiki/Sorting_algorithm

--
Ck
http://www.gfour.net

2007-02-01 05:46:58 · answer #2 · answered by KingPin 3 · 0 0

check out http://www.pscode.com for great sample codes

2007-02-01 08:44:21 · answer #3 · answered by Richard H 7 · 0 0

you need two for loops, if and swapping two elements if necessary

2007-02-01 04:33:33 · answer #4 · answered by iyiogrenci 6 · 0 0

fedest.com, questions and answers