2.2.3-2

将所有元素逆置,空间复杂度O(1)

//逆序  空间复杂度为O(1)
void rever(Sq &s){
    
    int temp;
    for(int i=0;i<s.length/2;i++){
        temp = s.A[i];
        s.A[i] = s.A[s.length-i-1];
        s.A[s.length-i-1] = temp;
    }
}

猜你喜欢

转载自www.cnblogs.com/qing-mo/p/10904368.html
今日推荐