.下列算法為奇偶交換排序思路如下第一趟對所有奇數的i將a[i]和a[i+]進行比較第二趟對所有偶數的i將a[i]和a[i+]進行比較每次比較時若a[i]>a[i+]將二者交換;以後重復上述二趟過程直至整個數組有序
程序(a)
PROCEDURE oesort(VAR a:ARRAY[n] OF integer);
VAR flag:boolean; it:integer;
BEGIN
REPEAT
flag:=false;
FOR i:= TO n step DO
IF(a[i]>a[i+]) THEN
[flag:= ____()____; t:=a[i+]; a[i+]:=a[i]; ____()____]
FOR i:= ____()____ DO
IF (a[i]>a[i+]) THEN
[flag:= ____()____ ; t:=a[i+];a[i+]:=a[i]; a[i]:=t;]
UNTIL ____()____ ;
END;
程序(b)
void oesort (int a[n])
{int flagit;
do {flag=;
for(i=;i<n;i++i++)
if(a[i]>a[i+])
{flag=____()____; t=a[i+]; a[i+]=a[i]; ____()____;}
for ____()____
if (a[i]>a[i+])
{flag=____()____;t=a[i+]; a[i+]=a[i]; a[i]=t;}
}while ____()____;
}【上海大學 一 (分)】
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []
From:http://tw.wingwit.com/Article/program/sjjg/201311/22969.html