请问,谁能帮忙把这个升序排序程序改成降序排序程序啊?
升序程序:rest (int a[],int n)
{
int i,low,high,t;
for(i=0,low=0,high=n-1;i<=high;)
{
if(a[i]>0)
{
/*a[i]与a[high]交换,随之high减1*/
t=a[i];
a[i]=a[high];
a[high]=t;
high--;
}
else if (a[i]==0)
i++;/*略过读元素*/
else
{
/*a[i]与a[low]交换,随之low 增 1,i增 1*/
t=a[i];
a[i]=a[low];
a[low]=t;
low++;
i++;
}
}
}
int s[]={8,4,0,-1,6,0,-5};
main()
/*主函数用于测试rest函数 */
{
int i;
clrscr(); /* */
printf("\n The arry before rest is:\n");
for (i=0;i<sizeof(s)/sizeof(s[0]);i++)
printf("%4d",s[i]);
rest (s,sizeof(s)/sizeof(s[0]));
printf("\n The arry after test is:\n");
for (i=0;i<sizeof(s)/sizeof(s[0]);i++)
printf("%4d",s[i]);
printf("\n Press any key to quit...\n");
getch();
}
谁能帮帮忙把这个升序程序给改成降序程序啊??
[ 本帖最后由 xiaocat3 于 2010-3-3 00:54 编辑 ]