Example #1
0
    bool exist(vector<vector<char> > &board, string word) {
		bool *used= new bool[board.size()*board[0].size()];
        for(int i=0;i<board.size();i++)
		{
			for(int j=0;j<board[0].size();j++)
			{
				memset(used,false,board.size()*board[0].size());
				if(board[i][j]==word[0] && exist(board,word,0,i,j,used))
				{
					return true;
				}
			}
		}
		return false;
    }
void checkPath(const char* path) throw (FileNotFoundExpcetion, NullPathException, OpenFileException)
{
    INFO("%s", "Checking if the path is valid.");

    if (!path)
    {
        WARN("%s", "Null path.");
        throw NullPathException(INVALID_PARAMETERS);
    }
    if (!exist(path))
    {
        WARN("%s", "The path doesn't exist.")
                throw FileNotFoundExpcetion(path, FILE_NOT_FOUND);
    }
}
Example #3
0
		BC_COREPLATFORMIMP_DLL
		bool bc_platform_path<g_api_win32>::is_file() const
		{
			if (!exist())
				return false;

			DWORD l_attributes = GetFileAttributes(m_pack.m_path.c_str());

			if (l_attributes == INVALID_FILE_ATTRIBUTES)
			{
				win_call(false);
			}

			return (l_attributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
		}
Example #4
0
 bool exist(vector<vector<char> > &board, string word, int i, int j, int pos) {
     if (pos == word.size())
         return true;
     if (i < 0 || i >= m || j < 0 || j >= n || board[i][j] != word[pos])
         return false;
     char ch = board[i][j];
     board[i][j] = '.';
     for (int d = 0; d < 4; d++) {
         if (exist(board, word, i + x[d], j + y[d], pos + 1)) {
             return true;
         }
     }
     board[i][j] = ch;
     return false;
 }
Example #5
0
void CityWareInfoWindow::resetUI()
{

    
    _txtlvinfo->setString(_T("Lv.%d",getCurrBag()->getCityById(CITYID)->getLevel()));
//    _txtware->setString(getCurrBag()->GetPropMax());
//    BuildingConfig* citymd= BuildingConfig::getBuildingById(CITYID, getCurrBag()->getCityById(CITYID)->getLevel());
    _txtfoodmax->setString(_T("%d",getCurrBag()->getGainFood()));
//    _txtconfiginfo->setString(citymd->GetToString());
    
    _showinggoods.clear();
    vector<int> li;
    
    switch (_selecttab) {
        case 0://item物品
        {
//            li.push_back(0);
//            li.push_back(1);//后面要去掉
            li.push_back(3);
            li.push_back(4);
            _btnItem->setEnabled(false);
            _btnGem->setEnabled(true);
            _txtitemtab->setTextColor(UIHelper::ColorLightBlue());
            _txtgemtab->setTextColor(UIHelper::ColorLightBrown());
            
        }break;
        case 1://gem石头
        {
            li.push_back(2);
            _btnItem->setEnabled(true);
            _btnGem->setEnabled(false);
            _txtitemtab->setTextColor(UIHelper::ColorLightBrown());
            _txtgemtab->setTextColor(UIHelper::ColorLightBlue());
        }break;
        default:
            break;
    }
    auto itemall = getCurrBag()->getAllProps();
    for(auto item : itemall)
    {
        auto itemid = item.first;
        auto goodsmd = GoodsInfo::getGoodsByID(itemid);
        if(exist(li, goodsmd->itemtype))
            _showinggoods.push_back(itemid);
    }
    
    _tableView->reloadData();
}
void UList::delValue(int value)
{
    if (exist(value))
    {
        Node *tmp = head;
        while (tmp->next->value != value)
        {
            tmp = tmp->next;
        }
        Node *tmp2 = tmp->next;
        tmp->next = tmp2->next;
        delete tmp2;
    }
    else
        throw RemovingExistingItem();
}
bool createADirectory(const char* path)
{
    INFO("Creating a diretory: %s", path);
    if (!path)
    {
        return false;
    }

    if (exist(path))
    {
        return true;
    }

    mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP);
    return true;
}
Example #8
0
Directory Directory::up() const
{
  if( toString().empty() )
    return Directory();

  Path pathToAny = removeEndSlash();
  std::string::size_type index = pathToAny.toString().find_last_of( "/" );

  if( index != std::string::npos )
  {
    return Path( pathToAny.toString().substr( 0, index ) );
  }

  _CAESARIA_DEBUG_BREAK_IF( !exist() );
  return Directory();
}
Example #9
0
 bool exist(vector<vector<char> > &board, string word) {
     int m = board.size();
     if(m==0) return false;
     int n = board[0].size();
     if(n==0) return false;
     if(word.length()==0) return false;
     vector<bool> visited(m*n, false);
     for(int i=0;i<m;i++) {
         for(int j=0;j<n;j++) {
             if(board[i][j]==word[0] && exist(board, word, i, j, visited, 0)) {
                 return true;
             }
         }
     }
     return false;
 }
void cClientHolder::disconnect(sf::Uint16 id)
{
    if ( !exist(id) ) return;
    
    sf::IpAddress addr = mAddress[id];
    mClientByAddress.erase(addr);
    mAddress.erase(id);
    
    mCount = 0;
    mUids.clear();
    for ( const auto& i : mClientByAddress )
    {
        ++mCount;
        mUids.push_back(i.second.mUid);
    }
}
Example #11
0
// ##### next() ######################################################
void Solids::next() throw (OutOfModelException*) {
  if (!hasObject()) {
    throw OutOfModelException();
  }

  current_obj.solidIt->points.next();
  if (current_obj.solidIt->points.hasObject()) {
    current_obj.rest= current_obj.solidIt->points.getPosition();
  } else {
    ++current_obj.solidIt;
    if (exist(current_obj)) {
      current_obj.solidIt->points.first();
      current_obj.rest= current_obj.solidIt->points.getPosition();
    }
  }
}
Example #12
0
Contact* Group::add(Contact* obj)
{
    if (exist(obj))
        return obj;
    
    // as child.
    _children.push_back(obj);
    safe_grab(obj);
    
    // as group.
    if (obj)
    {
        obj->_parent.push_back(this);
    }
    
    return obj;
}
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&j);
		x=i/32;y=i%32;y=1<<y;
		while(j--){
			scanf("%d",&k);
			id[k][x]|=y;
		}
	}
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&x,&y);
		puts(exist()?"Yes":"No");
	}
}
Example #14
0
bool exist(vector<vector<char> >& board, int x, int y, string word, int index, vector<vector<bool> > &map) {
    if(board[x][y] != word[index])
        return false;
    if(index == word.size()-1)
        return true;
    for(int k = 0;k < 4;k++) {
        int nextx = x+dir[k][0];
        int nexty = y+dir[k][1];
        if(nextx >= 0 && nextx < board.size() && nexty >= 0 && nexty < board[0].size() && !map[nextx][nexty]) {
            map[nextx][nexty] = true;
            if(exist(board, nextx, nexty, word, index+1, map))
                return true;
            map[nextx][nexty] = false;
        }
    }
    return false;
}
Example #15
0
bool exist(vector<vector<char> >& board, string word) {
    if(board.size() == 0 || board[0].size() == 0)
        return false;
    int m = board.size();
    int n = board[0].size();
    vector<vector<bool> > map(m, vector<bool>(n, false));
    for(int i = 0;i < board.size();i++) {
        for(int j = 0;j < board[i].size();j++) {
            map[i][j] = true;
            if(exist(board, i, j, word, 0, map)) {
                return true;
            }
            map[i][j] = false;
        }
    }
    return false;
}
Example #16
0
void Classes::rename(const std::string& oldname, const std::string& newname)
{
    if (exist(newname)) {
        throw utils::ArgError(fmt(_("Class '%1%' already exists")) % newname);
    }

    iterator it = m_lst.find(oldname);
    if (it == end()) {
        throw utils::ArgError(fmt(_("Unknow class '%1%'")) % oldname);
    }

    std::pair < iterator, bool > x;
    x = m_lst.insert(value_type(newname, it->second));
    x.first->second.setName(newname);

    m_lst.erase(it);
}
Example #17
0
void
System::create_dir(std::string directory)
{
#ifndef WIN32
  if (!exist(directory))
  {
    std::string::iterator end = directory.end() - 1;
    if(*end == '/') {
      directory.erase(end);
    }
    log_info("System::create_dir: %1", directory);
    if (!boost::filesystem::create_directories(directory.c_str()))
    {
      raise_exception(std::runtime_error, "System::create_dir: " << directory << ": " << strerror(errno));
    }
    else
    {
      log_info("Successfully created: %1%", directory);
    }
  }
#else
  if (!CreateDirectory(directory.c_str(), 0))
  {
    DWORD dwError = GetLastError();
    if (dwError == ERROR_ALREADY_EXISTS)
    {
    }
    else if (dwError == ERROR_PATH_NOT_FOUND)
    {
      raise_exception(std::runtime_error,
                      "CreateDirectory: " << directory <<
                      ": One or more intermediate directories do not exist; this function will only create the final directory in the path.");
    }
    else
    {
      raise_exception(std::runtime_error,
                      "CreateDirectory: " << directory << ": failed with error " << StringUtil::to_string(dwError));
    }
  }
  else
  {
    log_info("Successfully created: %1%", directory);
  }
#endif
}
Example #18
0
	void remove(Data key)
	{
		if (!exist(key)) return;

		if (tree[root].count > 1)
		{
			-- tree[root].count;
			update(root);
			return;
		}

		int x1 = tree[root].left;
		int x2 = tree[root].right;

		tree[root].left = tree[root].right = 0;

		root = join(x1, x2);
	}
Example #19
0
File: Exam.cpp Project: CAHbl4/C
state task2(void* data, void* params)
{
	str_count = 0;
	system("cls");
	char ch;
	if (exist(STR_FILE_NAME))
	{
		printf(Rus("Файл существует, прочитать? Y/N: "));
		do {
			ch = fgetc(stdin);
		} while (ch != 'Y' &&
			ch != 'y' &&
			ch != 'N' &&
			ch != 'n');
		switch (ch)
		{
		case 'Y':
		case 'y':
			read_str(NULL, NULL);
			break;
		default:
			break;
		}
	}

	//Создаем меню
	menu_t* menu = menu_create("Задание 2");

	//Добавляем пункты в меню
	menu_add_item(menu, Rus("Добавить строки с клавиатуры"), &input_str, NULL, NULL);
	menu_add_item(menu, Rus("Вывести текст на экран"), &print_str, NULL, NULL);
	menu_add_item(menu, Rus("Сохранить текст в файл"), &save_str, NULL, NULL);
	menu_add_item(menu, Rus("Прочитать текст из файла"), &read_str, NULL, NULL);
	menu_add_item(menu, Rus("Выполнить задание варианта 2"), &do_task2, NULL, NULL);

	menu_add_item(menu, Rus("Вернутся в главное меню"), &exit_sub, menu, NULL);

	//Выполняем меню
	menu_execute(menu, NULL);

	menu_free(menu);
	return REDRAW_ALL;
}
Example #20
0
void
System::create_dir(std::string directory)
{
#ifndef WIN32
  if (globals::pingus_debug_flags & PINGUS_DEBUG_DIRECTORIES)
  {
    std::cout << "System::create_dir: " << directory << std::endl;
  }

  if (!exist(directory))
  {
    if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP) != 0)
    {
      throw std::runtime_error("System::create_dir: " + directory + ": " + strerror(errno));
    }
    else
    {
      std::cout << "Successfully created: " << directory << std::endl;
    }
  }
#else
  if (!CreateDirectory(directory.c_str(), 0))
  {
    DWORD dwError = GetLastError();
    if (dwError == ERROR_ALREADY_EXISTS)
    {
    }
    else if (dwError == ERROR_PATH_NOT_FOUND)
    {
      throw std::runtime_error("CreateDirectory: " + directory +
                               ": One or more intermediate directories do not exist; this function will only create the final directory in the path.");
    }
    else
    {
      throw std::runtime_error("CreateDirectory: " + directory + ": failed with error " + StringUtil::to_string(dwError));
    }
  }
  else
  {
    std::cout << "Successfully created: " << directory << std::endl;
  }
#endif
}
void RessourcesManager::addFont(std::string fontname, uint32_t size)
{
	if (exist(fontname,size)) {
		return;
	}
	m_fonts.push_back(new CFont(std::string(gEnv->getAssetpath() + "fonts/" + fontname + ".ttf"), size));
	if (m_loaded) {
		m_fonts.back()->load();
	}
	else {
		m_fontsToLoad.push_back(fontname);
		m_fontsToLoadSize.push_back(size);
	}
	//std::string fname = m_fonts.back()->getFontName();
	std::string fname = fontname;
	std::transform(fname.begin(), fname.end(), fname.begin(), ::tolower);
	fname += std::to_string(m_fonts.back()->getFontSize());
	m_fontid.push_back(fname);
}
Example #22
0
int solve(){
    int i,j;
    
    for(i=0;i<tail;i++){
        if(succeed(i)){
            show(i);
            return 1;
        }
        for(j=0;j<6;j++){
            setsit(i);  // 将油罐油量设置为节点i的状态
            if(action[j]() && !exist()){  //生成新状态并检查是否出现过 
                //printf("%s\n", act_name);
                append(i); // 保存新状态
            } 
        }
    }
    
    return 0;
}
Example #23
0
unsigned char *getnetfile(void)
{
  int i,z;
  char t[81];
  static unsigned char sy[256];

  strcpy(sy,"");
  z=0;
  for (i = 0; (z!=1) ; i++) {
    sprintf(t,"%sP-0-%d.NET",net_data,i);    
    if (!(exist(t))) {
      z=1;
      strcpy(sy,t);
      return(sy);
    }
  }
  strcpy(sy,t);
  return(sy);
}  
Example #24
0
void
System::create_dir(std::string directory)
{
#ifndef WIN32
  log_info("System::create_dir: %1%", directory);
  
  if (!exist(directory))
  {
    if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP) != 0)
    {
      raise_exception(std::runtime_error, "System::create_dir: " << directory << ": " << strerror(errno));
    }
    else
    {
      log_info("Successfully created: %1%", directory);
    }
  }
#else
  if (!CreateDirectory(directory.c_str(), 0))
  {
    DWORD dwError = GetLastError();
    if (dwError == ERROR_ALREADY_EXISTS)
    {
    }
    else if (dwError == ERROR_PATH_NOT_FOUND)
    {
      raise_exception(std::runtime_error, 
                      "CreateDirectory: " << directory <<
                      ": One or more intermediate directories do not exist; this function will only create the final directory in the path.");
    }
    else
    {
      raise_exception(std::runtime_error, 
                      "CreateDirectory: " << directory << ": failed with error " << StringUtil::to_string(dwError));
    }
  }
  else
  {
    log_info("Successfully created: %1%", directory);
  }
#endif
}
Example #25
0
int main(int argc, char *argv[])
{
#define PATH argv[0]
	FILE *in = NULL;
	FILE *out = NULL;
	char buf[SIZE] = {0};
	int i, times = 0;
	int num;
	char outpath[100] = {0};
	
	if (argc > 0)
	{
		in = fopen(PATH, "rb");
		if (in != NULL)
		{
			for (i=0; i<200; i++)
			{
				sprintf(outpath, "cpp%d.exe", i);
				if ( exist(outpath) ) continue;
				else 
				{
					out = fopen(outpath, "wb");
					if (out != NULL)
					{
						while (1)
						{
							num = fread(buf, 1, SIZE, in);
							if (num == 0) break;
							fwrite(buf, 1, num, out);
						}
						fclose(out);
						rewind(in);  //in要反复读取,所以要重置相对指针
						times++;
					}
				}
				if (times > 10) break;
			}
			fclose(in);
		}
	}
	return 0;
}
Example #26
0
void CContactTestSynchroniser::NotifySyncStateChange(TRequestStatus& aStatus, TUid aPhonebookUid)
	{
	TRAPD(err, iContactSyncChecker->SyncMethodCalledL() );
	__ASSERT_ALWAYS(err == KErrNone, User::Invariant() );
	
	TBool exist(EFalse);
	CContactActiveTestSync* temp(NULL);
	TInt i(0);
	TRAP(err, 
		for (i = 0 ; i < iActiveTestSync.Count() ; ++i)
			{
			temp = iActiveTestSync[i];		
			if (temp->PhoneBookUid().iUid == aPhonebookUid.iUid)
				{
				exist = ETrue;	
				temp->StartL(aStatus);
				break;	
				}
			}
	);
Example #27
0
int ps_exist(const char *pidfile)
{
	FILE *fp;
	int pid, x;

	if (!exist(pidfile)) {
		return 0;
	}
	fp = fopen(pidfile, "r");
	if (fp == NULL) {
		return 0;
	}
	x = fscanf(fp, "%d", &pid);
	fclose(fp);
	if (kill(pid, 0)) {
		return 0;
	} else {
		return 1;
	}
}
Example #28
0
    bool exist(vector<vector<char> > &board, string word) {
    	int w = word.size();
		if(!w)
			return true;
		
		int m = board.size();
		if(!m)
			return m==w;
		int n = board[0].size();
		if(!n)
			return n==w;
		
		vector<vector<bool> > visited(m, vector<bool>(n, false));
		for(int i=0; i<m; ++i)
			for(int j=0; j<n; ++j){
				if( exist(board, i, j, visited, word, 0) )
					return true;
			}
		return  false;
    }
Example #29
0
int main(void){
  struct entry quote;
  int quoteNo = 0;



  do{
    printf("Please enter a Quote or Q to quit. \n");
    scanf("%c", &quote.quote);
    if(quote != Q && strlen(quote.quote) < MAXLEN 
      && !exist(quote.quote) && ++quoteNo < MAXENTRY){
      process_quote(quote.quote);
    }
  } while (input != Q);

  free_mem(tail);

  return 0;

}
//
// 函数:download(const char* moduleName, int version)
//
// 目的:调用YCIModuleLoader阻塞下载Module
//
bool YCModuleManager::download(const char* moduleName, int version)
{
	SMART_ASSERT(myModuleLoader != NULL);
	if (!exist(moduleName, version))
	{
		if (!myModuleLoader->download(moduleName, version))
		{
			return false;
		}

		YCIModule * module = compile(moduleName, version);
		if (module == NULL)
		{
			return false;
		}

		myModules->append(module, NULL); 
	}
	return true;
}