【发布时间】:2014-03-25 06:33:45
【问题描述】:
为标题道歉,但我希望它有意义。
我正在尝试基于数组分配项目编号 [基于运行的循环数]。我真的希望这是有道理的。
//declare variables
int[] listToSort;
int listSize, minIndex, min, tmp, item;
int randNum;
//create scanner
Scanner myScanner = new Scanner(System.in);
//ask user first question
System.out.println("Size of list to sort?");
//set first question answer to variable "listSize"
listSize = myScanner.nextInt();
//Create array size based on the answer of the first question
listToSort = new int[listSize];
//Repeat loop
for (int i = 0; i < listToSort.length; i++){
//Generate random number between 0 - 100
randNum = 1 + (int) (Math.random() * (100 - 1 + 1));
//Set array to random number
listToSort[i] = randNum;
}
int pass = 1;
for (int i = 0; i < listToSort.length;){
minIndex = pass;
//set min to item "pass" of "listToSort"
????????????
我得到了一些 Scribble 伪代码来帮助我,但仍然没有运气。希望有人能让我更清楚一点。
感谢大家的帮助
【问题讨论】:
-
不知道这个问题是关于什么的。
-
如果我没有像@jelinson 那样清楚地解释它,我深表歉意。