本文整理汇总了C++中qs函数的典型用法代码示例。如果您正苦于以下问题:C++ qs函数的具体用法?C++ qs怎么用?C++ qs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qs
void qs(int l,int r)
{
int w,x,j;
i=l;
j=r;
p=(l+r)/2;
x=mas[p];
do
{
while (mas[i]<x)
{
i++;
};
while (x<mas[j])
{
j--;
};
if (i<=j)
{
w=mas[i];
mas[i]=mas[j];
mas[j]=w;
i++;
j--;
}
}
while (i<=j);
if (l<j) {qs(l,j);};
if (i<r) {qs(i,r);};
}
示例2: qs
void StickerSetInner::gotSet(const MTPmessages_StickerSet &set) {
_pack.clear();
if (set.type() == mtpc_messages_stickerSet) {
const MTPDmessages_stickerSet &d(set.c_messages_stickerSet());
const QVector<MTPDocument> &v(d.vdocuments.c_vector().v);
_pack.reserve(v.size());
for (int32 i = 0, l = v.size(); i < l; ++i) {
DocumentData *doc = App::feedDocument(v.at(i));
if (!doc || !doc->sticker) continue;
_pack.push_back(doc);
}
if (d.vset.type() == mtpc_stickerSet) {
const MTPDstickerSet &s(d.vset.c_stickerSet());
_setTitle = qs(s.vtitle);
_title = st::boxTitleFont->m.elidedText(_setTitle, Qt::ElideRight, width() - st::btnStickersClose.width - st::boxTitlePos.x());
_setShortName = qs(s.vshort_name);
_setId = s.vid.v;
_setAccess = s.vaccess_hash.v;
}
}
if (_pack.isEmpty() || _setShortName.isEmpty()) {
App::wnd()->showLayer(new ConfirmBox(lang(lng_stickers_not_found), true), true);
} else {
int32 rows = _pack.size() / StickerPanPerRow + ((_pack.size() % StickerPanPerRow) ? 1 : 0);
resize(st::stickersPadding + StickerPanPerRow * st::stickersSize.width(), rows * st::stickersSize.height() + st::stickersAddOrShare);
}
_loaded = true;
emit updateButtons();
}
示例3: qs
int qs(int* mas, int left, int right)
{
int j = right, i = left, p = mas[(left+right/2)];
do
{
while (mas[i] < p) i++;
while (mas[j] > p) j--;
if (i < j)
{
int buf = mas[i];
mas[i] = mas[j];
mas[j] = buf;
i++;
j--;
}
}
while (i <= j);
if (i < right)
qs(mas, i, right);
if (left < j)
qs(mas, left,j);
}
示例4: qs
int qs(int a[],int i,int t)
{
if(i==t)
{a[i];}
else
{
int j,k,temp;
k=t;
for(j=i;j<=t;j++)
{if(a[j]>a[i])
{while(k!=j)
{if(a[k]<a[i])
{temp=a[k];
a[k]=a[i];
a[i]=temp;
k--;
break;}
k--;}}
if(k==j)
{temp=a[i];
a[i]=a[k];
a[k]=temp;
break;}
qs(a,i,k-1);
qs(a,k,t);
}}
for(i=0;i<10;i++)
printf("\n %d",a[i]);
return 0;}
示例5: qs
void qs(ITEM *item, int left, int right)
/**********************************************************************
this is the quick sort subroutine - it returns the values in
an array from high to low.
**********************************************************************/
{
register int i,j;
ITEM x,y;
i=left;
j=right;
x=item[(left+right)/2];
do {
while(item[i].Rank<x.Rank && i<right) i++;
while(x.Rank<item[j].Rank && j>left) j--;
if (i<=j) {
y=item[i];
item[i]=item[j];
item[j]=y;
i++;
j--;
}
} while (i<=j);
if(left<j) qs(item,left,j);
if(i<right) qs(item,i,right);
}
示例6: qs
void qs(list *l, int left, int right){
if (left < right){
int part = partition(l, left, right);
qs(l, left, part-1);
qs(l, part+1, right);
}
}
示例7: qs
//MÉTODO TIEMPO MILISEGUNDOS
void qs(int lista[],int fTempite_left,int fTempite_rig)
{
int left,rig,temporal,pivote;
left=fTempite_left;
rig = fTempite_rig;
pivote = lista[(left+rig)/2];
do{
while(lista[left]<pivote && left<fTempite_rig)left++;
while(pivote<lista[rig] && rig > fTempite_left)rig--;
if(left <=rig){
temporal= lista[left];
lista[left]=lista[rig];
lista[rig]=temporal;
left++;
rig--;
}
}
while(left<=rig);
if(fTempite_left<rig){
qs(lista,fTempite_left,rig);
}
if(fTempite_rig>left){
qs(lista,left,fTempite_rig);
}
}
示例8: qs
void qs(int a[], int l, int r)
{
if(l == r || l>r)
return;
if((r-l) == 1)
{
if(a[l] > a[r])
swap(&a[l],&a[r]);
return;
}
int index = pivot(a,l,r,2);
swap(&a[index],&a[l]);
int lt = l+1, rt = r;
while(lt < rt)
{
while(a[lt] < a[l])
lt++;
while(a[rt] > a[l])
rt--;
if(lt < rt)
{
swap(&a[lt],&a[rt]);
lt++;
rt--;
}
}
if(l != rt)
swap(&a[l],&a[rt]);
qs(a,l,rt-1);
qs(a,rt+1,r);
return;
}
示例9: qs
void qs (char *items, int left, int right)
{
int i, j;
int x, y;
i = left;
j = right;
x = items[ (left + right) / 2];
do {
while ((items[i] < x) && (i < right)) i++;
while ((x < items[j]) && (j > left)) j--;
if (i <= j) {
y = items[i];
items[i] = items[j];
items[j] = y;
i++; j--;
}
} while (i <= j);
if (left < j) qs (items, left, j);
if (i < right) qs (items, i, right);
}
示例10: qs
int qs(int l, int r)
{
if(l < r)
{
int key = buf[l];
int low = l;
int high = r;
while(low < high)
{
while(low < high && buf[high] >= key)
{
high --;
}
buf[low] = buf[high];
while(low < high && buf[low] <= key)
{
low++;
}
buf[high] = buf[low];
}
// printf("low = high: %d\n", low);
buf[low] = key;
qs(l, low-1);
qs(low+1, r);
}
}
示例11: qs
int qs(int s,int t)
{
int m,y,i,j,temp;
m=rand()%(t-s+1)+s;
temp=data[m];
data[m]=data[s];
data[s]=temp;
temp=num[m];
num[m]=num[s];
num[s]=temp;
y=data[s];
i=s;
j=t+1;
for(;i<j;)
{
for(i++;data[i]<y;i++);
for(j--;data[j]>y;j--);
if(i<j)
{
temp=data[i];
data[i]=data[j];
data[j]=temp;
temp=num[i];
num[i]=num[j];
num[j]=temp;
}
}
data[s]=data[j];
data[j]=y;
temp=num[s];
num[s]=num[j];
num[j]=temp;
if(s<j-1)qs(s,j-1);
if(t>j+1)qs(j+1,t);
}
示例12: qs
void qs(int *arr, int begin, int end){
if(end - begin < 2)
return;
int pivot = partition(arr, begin, end);
qs(arr, begin, pivot);
qs(arr, pivot + 1, end);
}
示例13: qs
int qs(int *dat,int begin,int end)
{
printf("data = 0x%x,begin = %d,end = %d \n",dat,begin,end);
if(begin >= (end-1)) return 1;
int *data = dat;
int num = partion_mid(data,begin,end);
qs(data,begin,num-1);
qs(data,num+1,end);
return 1;
}
示例14: qs
void qs ( msg t[], int start, int end ) //递归实现快排
{
int mid;
if ( start < end )
{
mid = Qsort(t,start,end);
qs ( t,start,mid-1);
qs ( t,mid+1,end);
}
}
示例15: qs
void qs(int a[],int p,int q)
{
if(p<q)
{
part(a,p,q);
int b=s,c=t;
qs(a,p,b-1);
qs(a,b+1,c-1);
qs(a,c+1,q);
}
}