正在加载图片...
An Example of an algorithm Algorithm sorting(X, n Algorithm sorting(x, n) Input array X of n integers Input array X of n integers Output array X sorted in a non- Output array X sorted in a non- decreasing order ecreasing order for it0 to n-do forj←-计+ton-ldo for i fromo to n- do fori from i+l to n-1 do if (Xixlilthen if X/i is largerthan Xil S- swap(X/i,xn i/, return X return X lafter i-th round, the i-th smallest after i-th round, the i-th smallest number is at i-th position number is at i-th position StacksAn Example of an Algorithm Algorithm sorting(X, n) Input array X of n integers Output array X sorted in a non￾decreasing order for i  0 to n − 1 do for j  i+1 to n-1 do if (X[i]>X[j])then { s=X[i]; X[i]=X[j]; X[j]=s; } return X // after i-th round, the i-th smallest number is at i-th position. Stacks 9 Algorithm sorting(X, n) Input array X of n integers Output array X sorted in a non￾decreasing order for i from 0 to n − 1 do for j from i+1 to n-1 do if X[i] is larger than X[j] swap(X[i], X[j]) return X // after i-th round, the i-th smallest number is at i-th position
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有