理解下面算法,并补充完整。[br][/br] //算法功能:(1) public void insertSort() { int temp, position; for (int i = 1; i [ length; (2) ) { temp = record[i]; for (position = i; position ] 0 && temp < record[position -1]; (3) ) { record[position] = record[position - 1]; } record[position] = (4) ; } }[/i]
举一反三
- 下面代码的输出是什么? int [][] array = {{1, 2},{3, 4},{5,6}}; int sum = 0; for(int i = 0; i < array.length; i++) sum = sum + array[i][0]; System.out.println(sum);[/i]
- 已知列表m=[[1,2],[3,4]],有列表a=[[row[i] for row in m] for i in range(2)],则a[0][1]是[/i]
- 下面程序的运行结果是____。[br][/br]#include[br][/br]intmain()[br][/br]{[br][/br]inta[][3]={{1,2,3},{4,5,0}},(*pa)[3],i;[br][/br]pa=a;[br][/br]for(i=0;i[3;i++)<br]if(i[2)pa[1][i]=pa[1][i]–1;<br]elsepa[1][i]=1;[br][/br]printf("%d\n",a[0][1]+a[1][1]+a[1][2]);[br][/br]return0;[br][/br]}[/i][/i][/i]
- 有以下程序 void main() { int a[][3]={{1,2,3},{4,5,0}},(*pa)[3],i; pa=a; for(i=0;i<3;i++) if(i<2) pa[1][i]=pa[1][i]-1; else pa[1][i]=1; printf("%d\n",a[0][1]+a[1][1]+a[1][2]); } 执行后输出结果是______。[/i][/i][/i] A: 7 B: 6 C: 8 D: 无确定值
- 请阅读下面的程序 [br][/br]public class Test { [br][/br] public static void main(String[] args) { [br][/br] int a = { 2, 0, 4, 1, 8, 3, 5 }; [br][/br] int temp;[br][/br] for (int i = 0; i [ a.length - 1; i++) { <br] for (int j = a.length - 1; j > i; j--) {[br][/br] if (aj [ aj - 1) { <br] temp = aj; [br][/br] aj = aj - 1; [br][/br] aj - 1 = temp; [br][/br] }[br][/br] }[br][/br] }[br][/br] for (Integer i : a) {[br][/br] System.out.print(i); [br][/br] }[br][/br] }[br][/br]} [br][/br]下列选项中,哪个是程序的运行结果() A: 8543210 B: 0123458 C: 2041835 D: 以上答案都不对