2.21-顺序表就地逆转

#define max 100
typedef struct
{
	int elem[max];
	int length;
}Seqlist;

void Reverse(Seqlist &S)
{
	int ave=S.length>>1,temp,i;
	for(i=0;i<ave;i++)
	{
		temp=S.length-1-i;
		S.elem[i]^=S.elem[temp];
		S.elem[temp]^=S.elem[i];
		S.elem[i]^=S.elem[temp];
	}
}

你可能感兴趣的:(2.21-顺序表就地逆转)