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

C++ reverse函数代码示例

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

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



在下文中一共展示了reverse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: goSomewhere


//.........这里部分代码省略.........
	move_robot(s, 1, 1);
	ns = copy(s);
	
	do{
	    free(s);
	    s = copy(ns);
		update_world(ns, s);
		change++;
		stage++;
		end = 0;
		for(i=1; i <= s->world_w; i++){
			for(j=1; j <= s->world_h; j++){
				if(c[point_to_index(s,i,j)]==stage){
					if(get(s, i, j) == O_LIFT_OPEN || get(s, i, j) == O_LAMBDA){
						wx=i;
						wy=j;
						end=stage;
						break;
					}
					//consider four cells - (-1, 0), (1, 0), (0, -1), (0, 1)
					for(k = 1; k<=4; k++){
						if(k==1) {is= 0 ; js=-1;}
						if(k==2) {is= 0 ; js= 1;}
						if(k==3) {is=-1 ; js= 0;}
						if(k==4) {is= 1 ; js= 0;}						
						if(bounded(s,i+is,j+js)	&& c[point_to_index(s, i+is, j+js)]==UINT_MAX){
							//can we go there?
							if(	!bounded(s, i+is, j+js+1) || (get(s, i+is, j+js+1) != O_EMPTY || get(ns, i+is, j+js+1) != O_ROCK)){	
								if(get(s, i+is, j+js)==O_LIFT_OPEN 
								|| get(s, i+is, j+js)==O_LAMBDA 
								|| get(s, i+is, j+js)==O_EARTH 
								|| get(s, i+is, j+js)==O_EMPTY){
									if((bounded(s, i+is, j+js+1) && get(s, i+is, j+js+1)==O_ROCK)
										|| (bounded(s, i+is+1, j+js+1) && get(s, i+is+1, j+js)==O_ROCK && get(s, i+is+1, j+js+1)==O_ROCK)
										|| (bounded(s, i+is-1, j+js+1) && get(s, i+is-1, j+js)==O_ROCK && get(s, i+is-1, j+js+1)==O_ROCK)){
										c[point_to_index(s, i+is, j+js)]=stage+penalty;
									}else{
										c[point_to_index(s, i+is, j+js)]=stage+1;
									}
									change = 0;
							    }
							}
						}
					}
				}
			}
		}
	}while(change <= penalty && end == 0);
	
	//debug
	//dump(s);
	
	if(0){
		for(j=s->world_h; j>0; j--){
			for(i=1; i<=s->world_w; i++){
				if(c[point_to_index(s, i, j)]==UINT_MAX){
					printf("X");
				}else{
					printf("%u", c[point_to_index(s, i, j)]);
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	i=0;
	if(end>0){
		answer = malloc( (end+2)*sizeof( char ));
		if (answer == NULL ){}
		
		while(end>0){
			for(k=1; k<=4;k++){
				if(k==1) {is=-1; js= 0;move='R';}
				if(k==2) {is= 1; js= 0;move='L';}						
				if(k==3) {is= 0; js=-1;move='U';}
				if(k==4) {is= 0; js= 1;move='D';}
				if( bounded(s, wx+is, wy+js) && c[point_to_index(s, wx+is, wy+js)] < end) {
					end = c[point_to_index(s, wx+is, wy+js)];
					answer[i++]=move;
					wx = wx+is;
					wy = wy+js;
					break;
				}
			}
		}
		answer[i]='\0';
		reverse(answer,0,strlen(answer)-1);
	}else{
		answer = malloc(1*sizeof( char ));
		if (answer == NULL ){}
		answer[0]='\0';
     	*a=answer;
		free(c);
		return 1;
	}
	*a=answer;
	free(c);
	return 0;
}
开发者ID:mietek,项目名称:icfp-contest-2012,代码行数:101,代码来源:main.c


示例2: fopen

int B011001::loadTextureBMP(char* file)
{
	unsigned int   texture_ID;
	FILE*          file_Pointer;
	unsigned short magic;      // Image magic
	unsigned int   dx,dy,size; // Image dimensions
	unsigned short nbp,bpp;    // Planes and bits per pixel
	unsigned char* image;      // Image data
	unsigned int   k;          // Counter

	//  Open file
	file_Pointer = fopen(file,"rb");

	if (!file_Pointer) fatal("Cannot open file %s\n", file);
	
	//  Check image magic
	if (fread(&magic,2,1,file_Pointer)!=1) fatal("Cannot read magic from %s\n",file);
	if (magic!=0x4D42 && magic!=0x424D) fatal("Image magic not BMP in %s\n",file);
	
	//  Seek to and read header
	if (fseek(file_Pointer,16,SEEK_CUR) || fread(&dx ,4,1,file_Pointer)!=1 || fread(&dy ,4,1,file_Pointer)!=1 ||
		fread(&nbp,2,1,file_Pointer)!=1 || fread(&bpp,2,1,file_Pointer)!=1 || fread(&k,4,1,file_Pointer)!=1)
		fatal("Cannot read header from %s\n",file);
	
	//  Reverse bytes on big endian hardware (detected by backwards magic)
	if (magic==0x424D)
	{
		reverse(&dx,4);
		reverse(&dy,4);
		reverse(&nbp,2);
		reverse(&bpp,2);
		reverse(&k,4);
	}
	
	//  Check image parameters
	if (dx<1 || dx>65536) fatal("%s image width out of range: %d\n",file,dx);
	if (dy<1 || dy>65536) fatal("%s image height out of range: %d\n",file,dy);
	if (nbp!=1)  fatal("%s bit planes is not 1: %d\n",file,nbp);
	if (bpp!=24) fatal("%s bits per pixel is not 24: %d\n",file,bpp);
	if (k!=0)    fatal("%s compressed files not supported\n",file);

#ifndef GL_VERSION_2_0
	//  OpenGL 2.0 lifts the restriction that texture size must be a power of two
	for (k=1;k<dx;k*=2);
	if (k!=dx) fatal("%s image width not a power of two: %d\n",file,dx);
	for (k=1;k<dy;k*=2);
	if (k!=dy) fatal("%s image height not a power of two: %d\n",file,dy);
#endif

	//  Allocate image memory
	size = 3*dx*dy;
	image = (unsigned char*) malloc(size);
	if (!image) fatal("Cannot allocate %d bytes of memory for image %s\n",size,file);
	//  Seek to and read image
	if (fseek(file_Pointer,20,SEEK_CUR) || fread(image,size,1,file_Pointer)!=1) fatal("Error reading data from image %s\n",file);
	fclose(file_Pointer);
	//  Reverse colors (BGR -> RGB)
	for (k=0;k<size;k+=3)
	{
		unsigned char temp = image[k];
		image[k]   = image[k+2];
		image[k+2] = temp;
	}

	//  Generate 2D texture
	glGenTextures(1,&texture_ID);
	glBindTexture(GL_TEXTURE_2D,texture_ID);
	//  Copy image
	glTexImage2D(GL_TEXTURE_2D,0,3,dx,dy,0,GL_RGB,GL_UNSIGNED_BYTE,image);
	if (glGetError()) fatal("Error in glTexImage2D %s %dx%d\n",file,dx,dy);
	//  Scale linearly when image size doesn't match
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

	//  Free image memory
	free(image);
	//  Return texture name
	return texture_ID;
}
开发者ID:ovekyc,项目名称:Computer_Graphics_2015_3_2,代码行数:79,代码来源:B011001.cpp


示例3: reversed_binary_value

int reversed_binary_value(...)
{
    return reverse(sizeof...(digits), digits...);
}
开发者ID:ynyeh0221,项目名称:Hackerrank,代码行数:4,代码来源:C+++Variadics.cpp


示例4: while

// performs the backtrace algorithm
void CBandedSmithWaterman::Traceback(unsigned int& referenceAl, string& cigarAl, const string& s1, const string& s2, unsigned int bestRow, unsigned int bestColumn, const unsigned int rowOffset, const unsigned int columnOffset){


	unsigned int currentRow		 = bestRow;
	unsigned int currentColumn	 = bestColumn;
	unsigned int currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);


	// record the numbers of row and column before the current row and column
	unsigned int previousRow	= bestRow;
	unsigned int previousColumn	= bestColumn;

	unsigned int gappedAnchorLen = 0;
	unsigned int gappedQueryLen  = 0;
	unsigned int numMismatches   = 0;

	bool keepProcessing = true;
	while(keepProcessing) {
		unsigned int nVerticalGap = 0;
		unsigned int nHorizontalGap = 0;
		switch(mPointers[currentPosition].Direction){
			case Directions_DIAGONAL:
				nVerticalGap = mPointers[currentPosition].mSizeOfVerticalGaps;
				for(unsigned int i = 0; i < nVerticalGap; i++){
					mReversedAnchor[gappedAnchorLen++] = GAP;
					mReversedQuery[gappedQueryLen++]   = s2[currentRow];

					numMismatches++;

					previousRow = currentRow;
					previousColumn = currentColumn;

					currentRow--;
				}
				break;

			case Directions_STOP:
				keepProcessing = false;
				//mReversedAnchor[gappedAnchorLen+1]='\0';
				//mReversedQuery [gappedQueryLen+1]='\0';
				break;

			case Directions_UP:

				mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
				mReversedQuery[gappedQueryLen++]   = s2[currentRow];

				if(s1[currentColumn] != s2[currentRow]) numMismatches++;
				previousRow = currentRow;
				previousColumn = currentColumn;

				currentRow--;
				currentColumn--;
				break;

			case Directions_LEFT:
				nHorizontalGap =  mPointers[currentPosition].mSizeOfHorizontalGaps;
				for(unsigned int i = 0; i < nHorizontalGap; i++){

					mReversedAnchor[gappedAnchorLen++] = s1[currentColumn];
					mReversedQuery[gappedQueryLen++]   = GAP;

					numMismatches++;

					previousRow = currentRow;
					previousColumn = currentColumn;


					currentColumn--;
				}
				break;
		}
		currentPosition = ((currentRow + rowOffset) * (mBandwidth + 2)) + (columnOffset - currentRow + currentColumn);
	}

	// correct the reference and query sequence order
	mReversedAnchor[gappedAnchorLen] = 0;
	mReversedQuery [gappedQueryLen] = 0;
	reverse(mReversedAnchor, mReversedAnchor + gappedAnchorLen);
	reverse(mReversedQuery,  mReversedQuery  + gappedQueryLen);

	//alignment.Reference = mReversedAnchor;
	//alignment.Query     = mReversedQuery;

	// assign the alignment endpoints
	//alignment.ReferenceBegin = previousColumn;
	//alignment.ReferenceEnd   = bestColumn;
	referenceAl  = previousColumn;
	/*  
	if(alignment.IsReverseComplement){
		alignment.QueryBegin = s2.length() - bestRow - 1; 
		alignment.QueryEnd   = s2.length() - previousRow - 1;
	} else {
		alignment.QueryBegin = previousRow; 
		alignment.QueryEnd   = bestRow;
	}
	*/
	
	//alignment.QueryLength	= alignment.QueryEnd - alignment.QueryBegin + 1;
//.........这里部分代码省略.........
开发者ID:Brainiarc7,项目名称:TS,代码行数:101,代码来源:BandedSmithWaterman.cpp


示例5: CC_CALLBACK_2

//------------------------------------------------------------------
//
// MenuLayerMainMenu
//
//------------------------------------------------------------------
MenuLayerMainMenu::MenuLayerMainMenu()
{
    _touchListener = EventListenerTouchOneByOne::create();
    _touchListener->setSwallowTouches(true);
    _touchListener->onTouchBegan = CC_CALLBACK_2(MenuLayerMainMenu::onTouchBegan, this);
    _touchListener->onTouchMoved = CC_CALLBACK_2(MenuLayerMainMenu::onTouchMoved, this);
    _touchListener->onTouchEnded = CC_CALLBACK_2(MenuLayerMainMenu::onTouchEnded, this);
    _touchListener->onTouchCancelled = CC_CALLBACK_2(MenuLayerMainMenu::onTouchCancelled, this);
    
    _eventDispatcher->addEventListenerWithFixedPriority(_touchListener, 1);

    // Font Item    
    auto spriteNormal = Sprite::create(s_MenuItem, Rect(0,23*2,115,23));
    auto spriteSelected = Sprite::create(s_MenuItem, Rect(0,23*1,115,23));
    auto spriteDisabled = Sprite::create(s_MenuItem, Rect(0,23*0,115,23));

    auto item1 = MenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback, this) );
    
    // Image Item
    auto item2 = MenuItemImage::create(s_SendScore, s_PressSendScore, CC_CALLBACK_1(MenuLayerMainMenu::menuCallback2, this) );

    // Label Item (LabelAtlas)
    auto labelAtlas = LabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.');
    auto item3 = MenuItemLabel::create(labelAtlas, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackDisabled, this) );
    item3->setDisabledColor( Color3B(32,32,64) );
    item3->setColor( Color3B(200,200,255) );
    
    // Font Item
    auto item4 = MenuItemFont::create("I toggle enable items", [&](Object *sender) {
		_disabledItem->setEnabled(! _disabledItem->isEnabled() );
	});

    item4->setFontSizeObj(20);
    item4->setFontName("Marker Felt");
    
    // Label Item (LabelBMFont)
    auto label = LabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt");
    auto item5 = MenuItemLabel::create(label, CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackConfig, this));

    // Testing issue #500
    item5->setScale( 0.8f );

    // Events
    MenuItemFont::setFontName("Marker Felt");
    // Bugs Item
    auto item6 = MenuItemFont::create("Bugs", CC_CALLBACK_1(MenuLayerMainMenu::menuCallbackBugsTest, this));

    // Font Item
    auto item7= MenuItemFont::create("Quit", CC_CALLBACK_1(MenuLayerMainMenu::onQuit, this));
    
    auto item8 = MenuItemFont::create("Remove menu item when moving", CC_CALLBACK_1(MenuLayerMainMenu::menuMovingCallback, this));
    
    auto color_action = TintBy::create(0.5f, 0, -255, -255);
    auto color_back = color_action->reverse();
    auto seq = Sequence::create(color_action, color_back, NULL);
    item7->runAction(RepeatForever::create(seq));

    auto menu = Menu::create( item1, item2, item3, item4, item5, item6, item7, item8,  NULL);
    menu->alignItemsVertically();
    
    
    // elastic effect
    auto s = Director::getInstance()->getWinSize();
    
    int i=0;
    Node* child;
    auto pArray = menu->getChildren();
    Object* pObject = NULL;
    CCARRAY_FOREACH(pArray, pObject)
    {
        if(pObject == NULL)
            break;

        child = static_cast<Node*>(pObject);

        auto dstPoint = child->getPosition();
        int offset = (int) (s.width/2 + 50);
        if( i % 2 == 0)
            offset = -offset;
        
        child->setPosition( Point( dstPoint.x + offset, dstPoint.y) );
        child->runAction( 
                          EaseElasticOut::create(MoveBy::create(2, Point(dstPoint.x - offset,0)), 0.35f) 
                        );
        i++;
    }

    _disabledItem = item3; item3->retain();
    _disabledItem->setEnabled( false );

    addChild(menu);
    menu->setPosition(Point(s.width/2, s.height/2));
}
开发者ID:FlavioFalcao,项目名称:NautiPlot,代码行数:98,代码来源:MenuTest.cpp


示例6: lessPeptideInfoSort

void ProteomeInfo::sortPeptideInfoDescending( vector< PeptideInfo * > & vpPeptideInfoInput, string sKey )
{	
	LessPeptideInfo lessPeptideInfoSort( sKey );
	sort( vpPeptideInfoInput.begin(), vpPeptideInfoInput.end(), lessPeptideInfoSort );
	reverse( vpPeptideInfoInput.begin(), vpPeptideInfoInput.end() );	
}	
开发者ID:chongle,项目名称:prorata,代码行数:6,代码来源:proteomeInfo.cpp


示例7: applyCC

obj applyCC( obj (*func)(obj, obj), obj v1, obj v2){
	if(type(v1)==LIST && type(v2)==LIST) {
		list l1=ul(v1), l2=ul(v2);
		list l=nil;
		for(; l1 && l2; l1=rest(l1), l2=rest(l2)){
			l= cons(call_fn(func, first(l1), first(l2)), l); 
		}
		if(l1 || l2) error("unmatched num. of elems. in the lists");
		return List2v(reverse(l));
	}
	obj lt,rt;
	if(type(v1)==tDblArray && type(v2)==tDblArray){
		int len = udar(v1).size;
		if(len != udar(v2).size) error("num mismatch");
		obj rr = dblArray(len);
//		obj rr = new dblarr(len);
		double* v = udar(rr).v;
		for(int i=0; i<len; i++){
			lt = Double(udar(v1).v[i]);//íxÇ¢
			rt = Double(udar(v2).v[i]);
			obj rx = call_fnr(func, lt,rt);
		//	release(lt);
		//	release(rt);
			if(type(rx)!=tDouble) error("array: type mismatch");//kore mondai
			v[i] = udbl(rx);
			release(rx);
		}
		return rr;
	}
	if(isVec(type(v1)) && isVec(type(v2))){
		int len=size(v1);
		if(len!=size(v2)) error("num mismatch");
		obj rr = aArray(len);
		for(int i=0; i<len; i++){
			lt = ind(v1,i);
			rt = ind(v2,i);
			uar(rr).v[i] = call_fnr(func, lt, rt); 
		//	release(lt);
		//	release(rt);
		}
		return rr;
	}
	if( type(v1)==LIST && isVec(type(v2))){
		list l=nil, l1=ul(v1);
		int len=size(v2);
		for(int i=0; i<len; i++,l1=rest(l1)){
			if(! l1) error("num mismatch");
			rt = ind(v2,i);
			l = cons(call_fn(func, first(l1), rt), l);
			release(rt);
		}
		return List2v(reverse(l));
	}
	if( isVec(type(v1)) && type(v2)==LIST){
		list l=nil, l2=ul(v2);
		int len=size(v1);
		for(int i=0; i<len; i++,l2=rest(l2)){
			if(! l2) error("num mismatch");
			lt=ind(v1,i);
			l=cons(call_fn(func, lt, first(l2)), l);
			release(lt);
		}
		return List2v(reverse(l));
	}
	error("operation not defined.");
	return nil;
}
开发者ID:mogami29,项目名称:cipher-shell,代码行数:67,代码来源:eval.cpp


示例8: description

  bool OBMoleculeFormat::ReadChemObjectImpl(OBConversion* pConv, OBFormat* pFormat)
  {
    std::istream &ifs = *pConv->GetInStream();
    if (!ifs.good())
      return false;

    OBMol* pmol = new OBMol;

    std::string auditMsg = "OpenBabel::Read molecule ";
    std::string description(pFormat->Description());
    auditMsg += description.substr(0,description.find('\n'));
    obErrorLog.ThrowError(__FUNCTION__,
                          auditMsg,
                          obAuditMsg);

    if(pConv->IsOption("C",OBConversion::GENOPTIONS))
      return DeferMolOutput(pmol, pConv, pFormat);

    bool ret=true;
   if(pConv->IsOption("separate",OBConversion::GENOPTIONS))
   {
     //On first call, separate molecule and put fragments in MolArray.
     //On subsequent calls, remove a fragment from MolArray and send it for writing
     //Done this way so that each fragment can be written to its own file (with -m option)
     if(!StoredMolsReady)
     {
       while(ret) //do all the molecules in the file
       {
         ret = pFormat->ReadMolecule(pmol,pConv);

         if(ret && (pmol->NumAtoms() > 0 || (pFormat->Flags()&ZEROATOMSOK)))
         {
           vector<OBMol> SepArray = pmol->Separate(); //use un-transformed molecule
           //Add an appropriate title to each fragment
           if(SepArray.size()>1)
             for(int i=0;i<SepArray.size();++i)
             {
               stringstream ss;
               ss << pmol->GetTitle() << '#' << i+1;
               string title = ss.str();
               SepArray[i].SetTitle(title);
             }
           else
              SepArray[0].SetTitle(pmol->GetTitle());

           copy(SepArray.begin(),SepArray.end(),back_inserter(MolArray));
         }
       }
       reverse(MolArray.begin(),MolArray.end());
       StoredMolsReady = true;
       //Clear the flags of the input stream(which may have found eof) to ensure will
       //try to read anothe molecule and allow the stored ones to be sent for output.
       pConv->GetInStream()->clear();
     }

     if(MolArray.empty()) //normal end of fragments
       ret =false;
     else
     {
       // Copying is needed because the OBMol passed to AddChemObject will be deleted.
       // The OBMol in the vector is deleted here.
       OBMol* pMolCopy = new OBMol( MolArray.back());
       MolArray.pop_back();
       ret = pConv->AddChemObject(
           pMolCopy->DoTransformations(pConv->GetOptions(OBConversion::GENOPTIONS), pConv))!=0;
     }
     if(!ret)
       StoredMolsReady = false;

     delete pmol;
     return ret;
   }

    ret=pFormat->ReadMolecule(pmol,pConv);

    OBMol* ptmol = NULL;
    //Molecule is valid if it has some atoms
    //or the format allows zero-atom molecules and it has a title or properties
    if(ret && (pmol->NumAtoms() > 0 
      || (pFormat->Flags()&ZEROATOMSOK && (*pmol->GetTitle() || pmol->HasData(1)))))
    {
      ptmol = static_cast<OBMol*>(pmol->DoTransformations(pConv->GetOptions(OBConversion::GENOPTIONS),pConv));
      if(ptmol && (pConv->IsOption("j",OBConversion::GENOPTIONS)
                || pConv->IsOption("join",OBConversion::GENOPTIONS)))
      {
        //With j option, accumulate all mols in one stored in this class
        if(pConv->IsFirstInput())
          _jmol = new OBMol;
        pConv->AddChemObject(_jmol);
        //will be discarded in WriteChemObjectImpl until the last input mol. This complication
        //is needed to allow joined molecules to be from different files. pOb1 in AddChem Object
        //is zeroed at the end of a file and _jmol is in danger of not being output.
        *_jmol += *ptmol;
        delete ptmol;
        return true;
      }
    }
    else
      delete pmol;

//.........这里部分代码省略.........
开发者ID:Antipina,项目名称:OpenBabel-BFGS,代码行数:101,代码来源:obmolecformat.cpp


示例9: test1

 constexpr bool test1(int n) {
   char stuff[100] = "foobarfoo";
   const char stuff2[100] = "oofraboof";
   reverse(stuff, stuff + n); // expected-note {{cannot refer to element 101 of array of 100 elements}}
   return equal(stuff, stuff + n, stuff2, stuff2 + n);
 }
开发者ID:Nanosim-LIG,项目名称:SPIR,代码行数:6,代码来源:constant-expression-cxx1y.cpp


示例10: back

void back(int foot)
{
	Nova=reverse(Nova);
	forward(foot);
}
开发者ID:HaochenLiu,项目名称:POJ-snuc,代码行数:5,代码来源:1835.c


示例11: right

void right(int foot)
{
	Nova=reverse(Left[Nova][Head]);
	forward(foot);
}
开发者ID:HaochenLiu,项目名称:POJ-snuc,代码行数:5,代码来源:1835.c


示例12: main

int main(void) {
        List lista;
        ListNode temp_node;
        int i;
        double temp_array[6];
        lista = create();
        if(add(&lista, 1, 10.5) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }
        if(add(&lista, 2, 76) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }
        if(add(&lista, 1, 63) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }
        if(add(&lista, 3, 109.73) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }
        if(add(&lista, 2, 1903.78) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }

        if(add(&lista, 6, 7.5) == -1)
        {
                printf("apetuxe h eisagwgh neou stoixeiou sti listas\n");
                return 0;
        }
//        PrintAll(lista);        //63, 1903.78, 10.5, 109.73, 76, 7.5
        i=1;
        temp_node=lista.Head;
        while(i<=lista.megethos){
             temp_array[i-1]=temp_node->dedomena;
             i=i+1;
             temp_node=temp_node->epomenos;
        }
        reverse(&lista);
        temp_node=lista.Head;
        for(i=0;i<6;i++){
             if(temp_array[5-i]!=temp_node->dedomena)
                  break;
             else{
                  temp_node=temp_node->epomenos;
             } 
        }
        if(i==6)
             printf("OK\n");
        else
             printf("Error\n");
//        printf("\nlista meta tin antistrofi:\n\n");
//        PrintAll(lista);
//        reverse(&lista);
//        printf("\nlista meta tin antistrofi:\n\n");
//        PrintAll(lista);
        destroy(&lista);
        return 1;
}
开发者ID:xristos89,项目名称:askisi1,代码行数:66,代码来源:test8.c


示例13: rotate

 void rotate(int nums[], int n, int k) {
     k = k % n;
     reverse(nums, nums + n);  //可以换成迭代器
     reverse(nums, nums + k);
     reverse(nums + k, nums + n);
 }
开发者ID:scottdwdwdw,项目名称:leetcode,代码行数:6,代码来源:RotateArray.cpp


示例14: insert_buffer

static int insert_buffer(losig_list* losig, lofig_list* lofig, int optim_level, long index)
{
   double capa, init_capa;
   cell_list* buffer;
   chain_list* namechain, *sigchain=NULL;
   char* signame;
   lofig_list* model;
   losig_list* losig_buf;
   loins_list* loins_buf;
   locon_list* locon;
   losig_list* losig_vdd=NULL, *losig_vss=NULL, *losig_aux;
   ptype_list* ptype, *buffer_ptype;
   double delay, best_delay, init_delay;
   loins_list* loins;
   chain_list* lofigchain,*newlofigchain=NULL;
   int buffer_is_better=0, change=1;    /*flags*/
   chain_list* pred;
   chain_list* temp;


   buffer=getCellbuffer();
   /*no buffer in library*/
   if (!buffer) return 0;
   
   if (!losig->NAMECHAIN) {
      fprintf(stderr,"insert_buffer: no name on signal\n");
      autexit(1);
   }

   best_delay=critical_delay(lofig);
   init_capa=getcapacitance(losig->NAMECHAIN->DATA);

   /*add buffer to netlist*/
   signame=getautoname(losig->NAMECHAIN->DATA);
   namechain=addchain(NULL,signame);
   losig_buf=addlosig(lofig,index,namechain,INTERNAL);
   putcapacitance(signame,0);
   putdelay(signame,0);
   model=getlofig(buffer->BEFIG->NAME,'A');
   
   /*search vdd and vss*/
   for (locon=lofig->LOCON; locon; locon=locon->NEXT) {
      if (isvdd(locon->NAME)) losig_vdd=locon->SIG;
      if (isvss(locon->NAME)) losig_vss=locon->SIG;
   }
   
   /*build list of signal*/
   for (locon=model->LOCON;locon; locon=locon->NEXT) {
      if (locon->DIRECTION==UNKNOWN) {
         fprintf(stderr,"BEH: 'linkage %s' in figure '%s' isn't accepted\n",
         locon->NAME,model->NAME);
         autexit(1);
      }
      if (isvdd(locon->NAME)) losig_aux=losig_vdd;
      else if (isvss(locon->NAME)) losig_aux=losig_vss;
      else if (locon->DIRECTION==OUT) losig_aux=losig_buf;
      else if (locon->DIRECTION==IN) losig_aux=losig;
      else {
         fprintf(stderr,"insert_buffer: buffer port '%s' unknown\n",locon->NAME);
         autexit(1);
      }
      sigchain=addchain(sigchain,losig_aux);
   }

   
   sigchain=reverse(sigchain);
   loins_buf=addloins(lofig,signame,model,sigchain);
   freechain(sigchain);
   /*to check changes*/
   init_delay=getdelay(losig->NAMECHAIN->DATA);
   init_capa=getcapacitance(losig->NAMECHAIN->DATA);
   loins_capacitance(loins_buf,1/*add capa*/);
  
   /*lofigchain*/
   for (locon=loins_buf->LOCON;locon; locon=locon->NEXT) {
      if (locon->DIRECTION==UNKNOWN) {
         fprintf(stderr,"BEH: 'linkage %s' in figure '%s' isn't accepted\n",
         locon->NAME,loins_buf->INSNAME);
         autexit(1);
      }
      if (isvdd(locon->NAME)) losig_aux=losig_vdd;
      else if (isvss(locon->NAME)) losig_aux=losig_vss;
      else if (locon->DIRECTION==OUT) losig_aux=losig_buf;
      else if (locon->DIRECTION==IN) losig_aux=losig;
      else {
         fprintf(stderr,"insert_buffer: buffer port '%s' unknown\n",locon->NAME);
         autexit(1);
      }
      ptype=getptype(losig_aux->USER,LOFIGCHAIN);
      if (!ptype) losig_aux->USER=addptype(losig_aux->USER,LOFIGCHAIN,addchain(NULL,locon));
      else ptype->DATA=addchain(ptype->DATA,locon);
   }
   
   /*move all instance after buffer*/
   ptype=getptype(losig->USER,LOFIGCHAIN);
   buffer_ptype=getptype(losig_buf->USER,LOFIGCHAIN);
   if (!ptype || !buffer_ptype) {
      fprintf(stderr,"insert_buffer: LOFIGCHAIN not found\n");
      autexit(1);
   }
//.........这里部分代码省略.........
开发者ID:AhmedAMohamed,项目名称:Alliance-VLSI-CAD-System,代码行数:101,代码来源:lon_optim_capa.c


示例15: isPalindrome

bool isPalindrome(unsigned int x){
	return x == reverse(x);
}
开发者ID:Cybuster,项目名称:Contest-Archive,代码行数:3,代码来源:10018+-+Reverse+and+Add.c


示例16: window

void window(int x1, int y1, int x2, int y2, char* title, char style){
	int i, title_len;	
	char tl,tr,bl,br,hl,vl,lt,rt;

	if(style == 1){
	tl = 218;
	tr = 191;
	bl = 192;
	br = 217;
	hl = 196;
	vl = 179;
	lt = 180;
	rt = 195;
	}
	else{
	tl = 201;
	tr = 187;
	bl = 200;
	br = 188;
	hl = 205;
	vl = 186;
	lt = 185;
	rt = 204;
	}

	title_len = strlen(title);

	/* Draw top/title */
	gotoxy(x1, y1);
	printf("%c%c",tl,lt);
	reverse(1);
	printf(" %s ",title);
	if(style == 1){
		printf("%*c", x2-x1-5-title_len,0);
		reverse(0);
		printf("%c%c",rt,tr);	
	}
	else{
		reverse(0);
		printf("%c",rt);
		for(i = x1+4+title_len; i<x2-1;i++)
			printf("%c",hl);
		printf("%c",tr);
	}

	/* Draw sides */
	for(i=(y1+1); i<y2; i++){
		gotoxy(x1,i);
		printf("%c",vl);
		gotoxy(x2,i);
		printf("%c",vl);
	}

	/* Draw bottom */
	gotoxy(x1,y2);
	printf("%c",bl);
	for(i = x1+1; i < x2; i++){
		printf("%c",hl);
	}
	printf("%c",br);
} 
开发者ID:s114898,项目名称:30010,代码行数:61,代码来源:ansi.c


示例17: main


//.........这里部分代码省略.........
		addr_len = sizeof(addr6_send);
	}

	addr_send->sa_family = family;
	addr_recv->sa_family = family;

	fd = socket(family, SOCK_DGRAM, IPPROTO_UDP);
	if (fd < 0) {
		perror("socket");
		exit(-errno);
	}

	ret = bind(fd, addr_recv, addr_len);
	if (ret < 0) {
		perror("bind");
		exit(-errno);
	}

	ret = connect(fd, addr_send, addr_len);
	if (ret < 0) {
		perror("connect");
		exit(-errno);
	}

	do {
		while (data[i].buf) {
			ret = send(fd, data[i].buf, data[i].len, 0);
			if (ret < 0) {
				perror("send");
				goto out;
			}

			if (flood) {
				i++;
				continue;
			}

			FD_ZERO(&rfds);
			FD_SET(fd, &rfds);
			tv.tv_sec = MAX_TIMEOUT;
			tv.tv_usec = 0;

			ret = select(fd + 1, &rfds, NULL, NULL, &tv);
			if (ret < 0) {
				perror("select");
				goto out;
			} else if (ret == 0) {
				if (data[i].expecting_reply) {
					fprintf(stderr,
						"Timeout while waiting "
						"idx %d len %d\n",
						i, data[i].len);
					timeout = i;
				}
				i++;
				continue;
			} else if (!FD_ISSET(fd, &rfds)) {
				fprintf(stderr, "Invalid fd\n");
				ret = i;
				goto out;
			}

			ret = recv(fd, buf, sizeof(buf), 0);
			if (ret <= 0) {
				perror("recv");
				ret = -EINVAL;
				goto out;
			}

			reverse(buf, ret);

			if (data[i].len != ret ||
			    memcmp(data[i].buf, buf, ret) != 0) {
				fprintf(stderr,
					"Check failed idx %d len %d\n",
					i, ret);
				ret = i;
				goto out;
			} else {
				printf(".");
				fflush(stdout);
			}

			i++;
		}

		if (flood)
			i = 0;

	} while (flood);

	ret = timeout;

	printf("\n");

out:
	close(fd);

	exit(ret);
}
开发者ID:pafcndg,项目名称:ndgIqSoftwareKit,代码行数:101,代码来源:echo-client.c


示例18: reverse

bool book::addBook()
{
	this->hide();
	return reverse(ui.vipLineEdit->text().toInt(), ui.bookTimeDateTimeEdit->dateTime(), ui.rowComboBox->currentText().toInt());
}
开发者ID:zweecn,项目名称:Bowling,代码行数:5,代码来源:book.cpp


示例19: subs0

obj subs0(obj v, obj * vars){
	assert(!! v);
	switch(v->type){
	case tSymbol:
		if(vars){		// macro
			obj vp = search_assoc(*vars, v);
			if(vp) return vp;
		//	vp = searchFunc(v, specials);
		//	if(vp) {release(vp); return retain(v);}
			obj (*func)(obj) = searchFunc(v, specials);
			if(func) return retain(v);
			vp = find_var(v);
			if(vp) {release(vp); return retain(v);}
			assert(0);
		//	return ref2var(add_assoc(*vars, v, Null()));
		} else {		// quasi-quote
			obj vp = find_var(v);
			if(vp) return vp;
			return retain(v);
		}
    case tAssign:{
		obj vp = search_assoc(*vars, car(v));	//macro-locals
		if(vp) goto nex;
	/*	vp = searchFunc(car(v), specials);		// not needed because cant assign to global
		if(vp) {release(vp); vp = retain(v); return vp;}
		vp = find_var(v);
		if(vp) {release(vp); vp = retain(v); return vp;}
	*/	vp = ref2var(nil);
		add_assoc(vars, car(v), vp);
nex:		return operate(tAssign, vp, subs0(cdr(v), vars));
	}
    case tArray:{
		obj r = aArray(uar(v).size);
		for(int i=0; i < uar(v).size; i++) uar(r).v[i] = subs0(uar(v).v[i], vars);
		return r;
	}
    case LIST:		//list
	case POW:
	case MULT:
	case DIVIDE:
	case ARITH:
	case CONDITION:
	case tIf:
	case tExec:
        {
		list l = phi();
		for(list s=ul(v); s; s=rest(s))  l = cons(subs0(first(s), vars), l);
		return render(type(v), reverse(l));
        }
	case tReturn:
		if(!uref(v)) return retain(v);
	case tMinus:
		return encap(v->type, subs0(uref(v), vars));
	case tClosure:
	case tArrow:
		return render(type(v), list3(subs0(em0(v),vars), subs0(em1(v), vars), nil));
	case tDefine:
	case tSyntaxDef:
		assert(0);
	case tInd:
	case tWhile:
		{
		obj st = subs0(cdr(v), vars);
		if(type(st)==LIST) st->type = tExec;
		return operate(v->type, subs0(car(v), vars), st);
		}
	case tOp:
		return operate(v->type, subs0(car(v), vars), subs0(cdr(v), vars));
	case INT:
	case tDouble:
	case TOKEN:
	case tNull:
	case tLAVec:
	case tDblArray:
	case tIntArr:
	case tDblAr2:
	case IMAGE:
	case STRING:
	case tBreak:
		return retain(v);
    default:
        break;
	}
	print(v);
	assert(0);
	return v;
}
开发者ID:mogami29,项目名称:cipher-shell,代码行数:87,代码来源:eval.cpp


示例20: sizeof

void Copenclspectrometer::filter_signal_zfactor(float *psamples, int *psamplenum, int start, int stop, float fmax)
{
//return;
  float fact[] = {64, 32, 16, 8, 4};
  int   i;
  float cutfrequency;
  int   scut;
  int   arsize;
  int   precision = 0;

  m_bhalfband = false;
  arsize = (int)(sizeof(fact) / sizeof(float));
  for (i = 0; i < arsize; i++)
    {
      if ((int)(2. * fmax) < (m_sampling_frequency / fact[i]) - precision)
	{
	  scut = fact[i] / 2;
	  cutfrequency = (float)m_sampling_frequency / fact[i];
#ifdef USEFIR_KERNEL
	  switch (scut * 2)
	    {
	    case 4:
	      m_pfir_coefs = xcoeffs4; // cuttoff = f / 4 samplingf = f / 2
	      break;
	    case 8:
	      m_pfir_coefs = xcoeffs8;
	      break;
	    case 16:
	      m_pfir_coefs = xcoeffs16;
	      break;
	    case 32:
	      m_pfir_coefs = xcoeffs32;
	    default:
	      m_pfir_coefs = xcoeffs64;
	      break;
	    }
	  if (scut >= 2)
	    {
	      m_bhalfband = true;
	      m_kfirparams.intracksize = *psamplenum;
	      m_kfirparams.decimation = scut;
//#define CPU_FIR
#ifdef CPU_FIR
	      double t1 = SDL_GetTicks();
	      m_bhalfband = false;
	      //downsample(psamples, *psamplenum, scut);
	      filterloop(psamples, m_pfir_coefs, &m_kfirparams);
	      double t2 = SDL_GetTicks();
	      //printf("filtering took %fms\n", t2 - t1);
#endif
	    }
#else
	  double t1 = SDL_GetTicks();
	  DSPCPPfilter_low_pass_Butterworth(psamples, *psamplenum, m_sampling_frequency, cutfrequency);
	  reverse(psamples, *psamplenum);
	  DSPCPPfilter_low_pass_Butterworth(psamples, *psamplenum, m_sampling_frequency, cutfrequency);
	  reverse(psamples, *psamplenum);
	  downsample(psamples, *psamplenum, scut);
	  double t2 = SDL_GetTicks();
	  //printf("filtering took %fms\n", t2 - t1);
#endif
	  m_kparams.tracksize /= scut;
	  m_kparams.start_sample /= scut;
	  m_kparams.stop_sample /= scut;
	  m_kparams.sampling_frequency = 2 * cutfrequency;
	  m_kparams.N = get_N(m_kparams.sampling_frequency);
	  *psamplenum /= scut;
	  //printf("cutoff=%f decimation=%d\n", cutfrequency, m_kfirparams.decimation);
	  return;
	}
    }
}
开发者ID:mandraga,项目名称:Scoreview-Base,代码行数:72,代码来源:openclfir.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ reverseComplement函数代码示例发布时间:2022-05-30
下一篇:
C++ rev函数代码示例发布时间: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