• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中qs函数的典型用法代码示例。如果您正苦于以下问题:C++ qs函数的具体用法?C++ qs怎么用?C++ qs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了qs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);};
}
开发者ID:aleksey-zhidkov,项目名称:School-stuff,代码行数:30,代码来源:QS.CPP


示例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();
}
开发者ID:S-A-M-H,项目名称:Telegraph,代码行数:32,代码来源:stickersetbox.cpp


示例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);
}	
开发者ID:AlexeyRabochy,项目名称:SPBU-tasks-1term,代码行数:26,代码来源:qsort.c


示例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;}
开发者ID:Harsi88,项目名称:codes,代码行数:30,代码来源:sortg.c


示例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);

}
开发者ID:michaeco,项目名称:DHSVM,代码行数:30,代码来源:SlopeAspect.c


示例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);
    }
}
开发者ID:talkdirty,项目名称:generic-list,代码行数:7,代码来源:sorters.c


示例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);
		}
	}
开发者ID:Natthaliee,项目名称:Practica2s12015_201212501,代码行数:27,代码来源:Practica2s12015_201212501.c


示例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;
}
开发者ID:kanishk7,项目名称:Code_,代码行数:35,代码来源:sort.c


示例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); 
        
}
开发者ID:verdastelo,项目名称:schildt_beginners_guide_to_c-,代码行数:27,代码来源:16_quicksort.cpp


示例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);
	}
}
开发者ID:jackpelf,项目名称:store,代码行数:26,代码来源:qs.c


示例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);
}
开发者ID:neveralso,项目名称:ACM,代码行数:35,代码来源:r.c


示例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);
}
开发者ID:zhaosjason,项目名称:practice,代码行数:8,代码来源:quicksort.c


示例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;
}
开发者ID:ZhangZhenhua,项目名称:experiment-coding,代码行数:10,代码来源:qs.c


示例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);
	}
}
开发者ID:fengrenchang86,项目名称:PKU,代码行数:10,代码来源:1871786_TLE.cpp


示例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);
     }
}
开发者ID:kshav,项目名称:My_codes,代码行数:11,代码来源:quick+sort+2+variables.c


示例16: qs

void qs(int v[],int l,int r){
    int i, j,loop, pivo, y;
    i = l;
    j = r;
    //if(l!=r){ 
       pivo = gerar_pivo(v,l,r);
       PIVO p;
    
       p = achar_p(v,l,r,pivo);

       y = v[l];
       v[l]=v[p.pos];
       v[p.pos] = y; 
    
    do{
        while(i<r &&v[i]<=v[l]) i++;
        while(j>l && v[j]>v[l]) j--;
        if(i<j){
            y = v[i];
            v[i]=v[j];
            v[j] = y;
            i++; j--;
            //printf("xxx\n");
        }
    }while(i<j);
    y = v[l];
    v[l]=v[j];
    v[j] = y;

    printf("(%d,%d) %diiii %djjj %dlll %drrr \n", p.elem,j+1, i,j,l,r );
    for(loop=0;loop<5;loop++){
    	printf("%d \n",v[loop]);
    }
    
    /*else {printf("(%d,%d) %dyy\n", v[l],l+1, l );
         for(loop=0;loop<5;loop++){
    	printf("%d ",v[loop]);
    }
    }*/
    if(r==i)printf("(%d,%d) %diiii %djjj %dlll %drrr \n", v[j+1],j+2, i,j,l,r );
    if(l<(j-1)) qs(v,l,j-1);
    if(i<r){
        if((r+1)%2!=0){ 
        printf("%d %d entra impar\n",i,r);
    	qs(v,i+1,r);}
    	else {
    		printf("%d %d entra par\n",i,r);
    	    qs(v,i,r);
    	}
    }
}
开发者ID:cstiano,项目名称:Algorithm_exercices_cprogramming,代码行数:51,代码来源:quicksort.c


示例17: qs

void qs(int* array, int n) {
    int pivot = array[n / 2];
    int left = 0, right = n;
    while (left < right) {
        if (array[left] <= pivot)
            ++left;
        else if (array[right - 1] > pivot)
            --right;
        else
            iswap(&array[left], &array[right - 1]);
    }
    qs(&array[0], left);
    qs(&array[left], n - left);
}
开发者ID:harrychou,项目名称:computer_systems_src,代码行数:14,代码来源:qs0.c


示例18: HistoryItem

HistoryMessage::HistoryMessage(
	not_null<History*> history,
	const MTPDmessage &data)
: HistoryItem(
		history,
		data.vid.v,
		data.vflags.v,
		data.vdate.v,
		data.has_from_id() ? data.vfrom_id.v : UserId(0)) {
	CreateConfig config;

	if (data.has_fwd_from() && data.vfwd_from.type() == mtpc_messageFwdHeader) {
		auto &f = data.vfwd_from.c_messageFwdHeader();
		config.originalDate = f.vdate.v;
		if (f.has_from_id() || f.has_channel_id()) {
			config.senderOriginal = f.has_channel_id()
				? peerFromChannel(f.vchannel_id)
				: peerFromUser(f.vfrom_id);
			if (f.has_channel_post()) config.originalId = f.vchannel_post.v;
			if (f.has_post_author()) config.authorOriginal = qs(f.vpost_author);
			if (f.has_saved_from_peer() && f.has_saved_from_msg_id()) {
				config.savedFromPeer = peerFromMTP(f.vsaved_from_peer);
				config.savedFromMsgId = f.vsaved_from_msg_id.v;
			}
		}
	}
	if (data.has_reply_to_msg_id()) config.replyTo = data.vreply_to_msg_id.v;
	if (data.has_via_bot_id()) config.viaBotId = data.vvia_bot_id.v;
	if (data.has_views()) config.viewsCount = data.vviews.v;
	if (data.has_reply_markup()) config.mtpMarkup = &data.vreply_markup;
	if (data.has_edit_date()) config.editDate = data.vedit_date.v;
	if (data.has_post_author()) config.author = qs(data.vpost_author);

	createComponents(config);

	if (data.has_media()) {
		setMedia(data.vmedia);
	}

	auto text = TextUtilities::Clean(qs(data.vmessage));
	auto entities = data.has_entities()
		? TextUtilities::EntitiesFromMTP(data.ventities.v)
		: EntitiesInText();
	setText({ text, entities });

	if (data.has_grouped_id()) {
		setGroupId(MessageGroupId::FromRaw(data.vgrouped_id.v));
	}
}
开发者ID:devtoolch,项目名称:tdesktop,代码行数:49,代码来源:history_message.cpp


示例19: qs

void qs (int* items, int beg, int len) {
  if (len <= 1) {
    return;
  }
  int end = len - 1 + beg;
  int pivPos = rand() % (end - beg) + beg;
  int pivot = items[pivPos];

  swap(items, pivPos, end);
  int moves = partition(items, beg, end, pivot);
  swap(items, moves, end);

  qs(items, beg, moves - beg);
  qs(items, moves + 1, end - moves);
}
开发者ID:diogogmt,项目名称:qs,代码行数:15,代码来源:qs1.c


示例20: require_token

// assert_decl             = "assert" "(" identifier "," expression ")".
bool adam_test_parser::is_assert_decl() {
    if (is_keyword(assert_k)) {
        require_token(open_parenthesis_k);
        name_t name;
        if (!is_identifier(name))
            throw_exception("sheet name expected");
        queryable_sheet_t& qs(sheet_from_name(name));
        require_token(comma_k);
        array_t expression;
        if (!is_expression(expression))
            throw_exception("expression expected");
        require_token(close_parenthesis_k);
        any_regular_t result = qs.inspect(expression);
        bool success = result.cast<bool>();
        out_m << "\n### assert " << (success ? std::string("succeeded: ") : std::string("failed: "))
#if defined(ADOBE_STD_SERIALIZATION)
              << begin_asl_cel << expression << end_asl_cel
#endif
              << " in sheet " << name << std::endl;
        if (!success)
            all_checks_passed_m = false;
        return true;
    }
    return false;
}
开发者ID:BobArcher,项目名称:adobe_source_libraries,代码行数:26,代码来源:adam_test_parser.cpp



注:本文中的qs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qsort函数代码示例发布时间:2022-05-30
下一篇:
C++ qry函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap