示例#1
0
文件: splityacc.c 项目: ombt/ombt
// figure out the file name
void
setfname(char *parg)
{
	// check input parameters
	MustBeTrue(parg != NULL && *parg != 0);

	// check if file name option is on
	if (fileflag)
	{
		// file names are given, get directory
		strcpy(problemdir, parg);
		char *pdir = findlast(problemdir, '/');
		if (pdir != NULL)
			*pdir = 0;
		else
			strcpy(problemdir, ".");
		strcpy(filename, parg);
	}
	else
	{
		// a directory was given, use standard file name
		strcpy(problemdir, parg);
		sprintf(filename, "%s/axioms_conclusion", problemdir);
	}

	// all done
	return;
}
示例#2
0
StringData StringData::getExtName() const
{
	StringData strExt;
	int index = findlast(".");
	if (index != -1)
		strExt = substr(index + 1);
	return strExt;
}
示例#3
0
void ListPlayer::add (Player *pl)
{
	ListElem *elem = newplayer (pl); 
	ListElem *last = findlast (); 

	if ( first == 0 ) {
		first = elem;
	} else {
		last->next = elem;
	}
}
示例#4
0
文件: lgc.c 项目: charleeli/srpc
/*
** move all unreachable objects (or 'all' objects) that need
** finalization from list 'finobj' to list 'tobefnz' (to be finalized)
*/
static void separatetobefnz (global_State *g, int all) {
  GCObject *curr;
  GCObject **p = &g->finobj;
  GCObject **lastnext = findlast(&g->tobefnz);
  while ((curr = *p) != NULL) {  /* traverse all finalizable objects */
    lua_assert(tofinalize(curr));
    if (!(iswhite(curr) || all))  /* not being collected? */
      p = &curr->next;  /* don't bother with it */
    else {
      *p = curr->next;  /* remove 'curr' from 'finobj' list */
      curr->next = *lastnext;  /* link at the end of 'tobefnz' list */
      *lastnext = curr;
      lastnext = &curr->next;
    }
  }
}
void CBwfind::select(int flag)
{
	int step,i,j,cut=1000000,tf=flag;
	int tb[8][8];
	for(i=0;i<8;i++)for(j=0;j<8;j++) tb[i][j]=board[i][j];
	step=CountNum();
	//开局
	if(step<searchend){
		int ss=0;
		findfirst(tb,ss,tf,cut);
	}
	//终局
	else if(step>=searchend){
		preview=true;
		outcome=findlast(tb,step,tf,cut);
	}
}
int CBwfind::findlast(int tb[][8], int &step, int &flag, int cut)
{
	int value=0,max=-100000,min=100000,k=0,i,j;
	int temp[8][8];
	if(step==64){
		if(ComChoice==1) return(black(tb)-white(tb));
		else return(white(tb)-black(tb));
	}
	for(i=0;i<8;i++)for(j=0;j<8;j++) temp[i][j]=tb[i][j];
	for(i=0;i<8;i++)for(j=0;j<8;j++){
		if(judge(tb,i,j,flag)){
			int ii,jj;
			k=1;//存在合理的步子
			newboard(tb,i,j,flag);
			flag=-flag;
			step++;
			if(-flag==ComChoice){
				value=findlast(tb,step,flag,max);
			}
			if(-flag==ManChoice){
				value=findlast(tb,step,flag,min);
			}
			step--;
			flag=-flag;
			//恢复棋盘
			for(ii=0;ii<8;ii++)for(jj=0;jj<8;jj++) tb[ii][jj]=temp[ii][jj];
			if(flag-ManChoice==0&&value<cut) return value;
			if(flag-ComChoice==0&&value>cut) return value;
			if(flag-ManChoice==0){
				if(value<min){
					min=value;
				}
			}
			if(flag-ComChoice==0){
				if(value>max){
					max=value;
					if(step==CountNum()){
						stepx=i;
						stepy=j;
					}
				}
			}
		}//if
	}//for
	//当前没有步可走
	if(k==0){
		flag=-flag;
		if(search(tb,flag)){
			value=findlast(tb,step,flag,cut);
			flag=-flag;
			return value;
		}
		else{
			flag=-flag;
			if(ComChoice==1) return(black(tb)-white(tb));
			else return(white(tb)-black(tb));
		}
	}
	//存在合理步
	else{
		if(flag-ManChoice==0) return min;
		if(flag-ComChoice==0){
			return max;
		}

	}
}