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

C++ eat函数代码示例

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

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



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

示例1: philosopher_fn

void philosopher_fn(void* no){
    int i = (int)no;
    int right,count;
    right = (i+1)%NUM_CHOPSTICKS;
    for(count=0;count<NUM_ROUNDS;count++){
    printf("Philosopher %d going to think [%d]\n",i,count);
    think();
    sem_wait(&four_chairs);
    printf("Philosopher %d occupied a chair [%d]\n",i,count);
    pthread_mutex_lock(&mutex_arr[i]);
    pthread_mutex_lock(&mutex_arr[right]);
    printf("Philosopher %d locked chopsticks [%d]\n",i,count);
    printf("Philosopher %d going to eat [%d]\n",i,count);
    eat();
    printf("Philosopher %d going to unlock chopsticks [%d]\n",i,count);
    pthread_mutex_unlock(&mutex_arr[right]);
    pthread_mutex_unlock(&mutex_arr[i]);
    sem_post(&four_chairs);
    printf("Philosopher %d gave up a chair [%d]\n",i,count);
    }
}
开发者ID:gjpalathingal,项目名称:gjworks,代码行数:21,代码来源:diners_pblm_sem.c


示例2: readID

static Obj *readName( istream& is )
{
	string s = readID( is );

	if( s == "true" ) {
		return new BooleanObj( true );
	} else if( s == "false" ) {
		return new BooleanObj( false );
	} else {
		if( !eat( is ) ) {
			return new IdObj( s );
		}

		int ch = is.peek();
		if( strchr( "}),;", ch ) != NULL ) {
			return new IdObj( s );
		} else {
			return new NamedObj( s, readObject( is ) );
		}
	}
}
开发者ID:cychiuae,项目名称:recart-3tcetjorp-1144pmoc,代码行数:21,代码来源:parse.cpp


示例3: compileType

Type* compileType(void) {
  Type* type;
  Type* elementType;
  int arraySize;
  Object* obj;

  switch (lookAhead->tokenType) {
  case KW_INTEGER: 
    eat(KW_INTEGER);
    type =  makeIntType();
    break;
  case KW_CHAR: 
    eat(KW_CHAR); 
    type = makeCharType();
    break;
  case KW_ARRAY:
    eat(KW_ARRAY);
    eat(SB_LSEL);
    eat(TK_NUMBER);

    arraySize = currentToken->value;

    eat(SB_RSEL);
    eat(KW_OF);
    elementType = compileType();
    type = makeArrayType(arraySize, elementType);
    break;
  case TK_IDENT:
    eat(TK_IDENT);
    obj = checkDeclaredType(currentToken->string);
    type = duplicateType(obj->typeAttrs->actualType);
    break;
  default:
    error(ERR_INVALID_TYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  return type;
}
开发者ID:leaderwing,项目名称:test_repo,代码行数:38,代码来源:parser.c


示例4: eat

IMPLEMENT
int
Pic::irq_pending()
{
  unsigned int i;

  for (i = 0; i < highest_irq; i++)
    pfd[i].revents = 0;

  if (poll(pfd, highest_irq, 0) > 0)
    for (i = 0; i < highest_irq; i++)
      if (pfd[i].revents & POLLIN)
        {
	  if (!Emulation::idt_vector_present(0x20 + i))
            eat(i);
          else
            return i;
	}

  return -1;
}
开发者ID:KyulingLee,项目名称:Fiasco.OC,代码行数:21,代码来源:pic-ux.cpp


示例5: main

int main()
{
	hOut = GetStdHandle(STD_OUTPUT_HANDLE);  //标准输出句柄获得
	SetConsoleCursorInfo(hOut, &cur_info);  //隐藏光标
	while(1)
	{
		system("cls");/*清屏*/
		Snake* head = (Snake*)malloc(sizeof(Snake));
		initialization(head);
		background();
		while(1)
		{
			Sleep(500);
			refresh();
			getkeys();
			run(head);
			eat(head);
			if(door(head)) break;
			food(head);
		}
		release_list(head);
		SetConsoleCursorPosition(hOut, pos);
		SetConsoleTextAttribute(hOut, 0x07);
		system("cls");/*清屏*/
		printf("得分:%d\n空格重新开始\n",scoring);
		while(1)
		{
			int w = getch();
			if(w == ' ')
			{
				break;
			}
			else
			{
				continue;
			}
		}
	}
	return 0;
}
开发者ID:mjjOpencode2015,项目名称:My-Repository,代码行数:40,代码来源:Snake1.c


示例6: FACTOR

void FACTOR(void){
	/*factor 	::= 	<CONST_INT>
	| 	<CONST_FLOAT>
	| 	<CONST_BOOLEAN>
	| 	id restof_functioncall_or_epsilon
	| 	"(" assignment ")"*/
	switch(l){

	case CONST_INT:																	eat(CONST_INT);  return;
	case CONST_FLOAT:																eat(CONST_FLOAT); return;
	case CONST_BOOLEAN:																eat(CONST_BOOLEAN); return;
	case ID:																		eat(ID); RESTOF_FUNCTIONCALL_OR_EPSILON(); return;
	case '(':																		eat('('); ASSIGNMENT(); eat(')'); return;
	default:																		StdError(__func__);
	}
}
开发者ID:Bakkhos,项目名称:compilers,代码行数:16,代码来源:minako-syntax.c


示例7: compileType

Type* compileType(void) {
  Type* type;
  Type* elementType;
  int arraySize;
  Object* obj;

  switch (lookAhead->tokenType) {
  case KW_INTEGER: 
    eat(KW_INTEGER);
    type =  makeIntType();
    break;
  case KW_CHAR: 
    eat(KW_CHAR); 
    type = makeCharType();
    break;
  case KW_ARRAY:
    eat(KW_ARRAY);
    eat(SB_LSEL);
    eat(TK_NUMBER);

    arraySize = currentToken->value;

    eat(SB_RSEL);
    eat(KW_OF);
    elementType = compileType();
    type = makeArrayType(arraySize, elementType);
    break;
  case TK_IDENT:
    eat(TK_IDENT);
    // TODO: check if the type idntifier is declared and get its actual type
    break;
  default:
    error(ERR_INVALID_TYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  return type;
}
开发者ID:BichVN,项目名称:Compiler,代码行数:37,代码来源:parser.c


示例8: while

void Snake::init()
{
	con->clear();
	for (int i = 0; i < WIDTH; ++i)
		for (int j = 0; j < HEIGHT; ++j)
		{
			B[i][j] = 0;
		}

	for (int i = intLeft; i <= intRight; ++i)
	{
		con->putChar('*',i,intTop - 1);
		con->putChar('*',i,intBottom + 1);
		B[i][intTop - 1] = B[i][intBottom + 1] = -1; 
	}

	for (int i = intTop; i <= intBottom; ++i)
	{
		con->putChar('*',intLeft - 1,i);
		con->putChar('*',intRight + 1,i);
		B[intLeft - 1][i] = B[intRight + 1][i] = -1;
	}
	while (!snakeBody.empty()) snakeBody.pop();
	curDirect =  D_EAST;

	int midX = (intRight - intLeft) / 2 + intLeft;
	int midY = (intBottom - intTop) / 2 + intTop;

	snakeHead.X = midX;
	snakeHead.Y = midY;

	B[midX][midY] = -1;

	con->putChar(SNAKE_CHAR, snakeHead.X, snakeHead.Y);

	snakeBody.push(snakeHead);

	eat(D_EAST);
}
开发者ID:PhamHoangVu,项目名称:SnakeGame,代码行数:39,代码来源:Snake.cpp


示例9: compileExpression

void compileExpression(void) {
  assert("Parsing an expression");
  // TODO
  switch (lookAhead->tokenType) {
  case SB_PLUS:
  case SB_MINUS:
    eat(lookAhead->tokenType);
    compileExpression2();
    break;
  case TK_IDENT:
  case TK_CHAR:
  case TK_NUMBER:
  case SB_LPAR:
  case TK_STRING:
    compileExpression2();
    break;
  default:
    error(ERR_INVALIDEXPRESSION, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
  assert("Expression parsed");
}
开发者ID:BichVN,项目名称:Compiler,代码行数:22,代码来源:parser.c


示例10: compileType

void compileType(void) {
  switch(lookAhead->tokenType){
  case KW_INTEGER:
      eat(KW_INTEGER);
      break;
  case KW_CHAR:
      eat(KW_CHAR);
      break;
  case KW_ARRAY:
      eat(KW_ARRAY);
      eat(SB_LSEL);
      eat(TK_NUMBER);
      eat(SB_RSEL);
      eat(KW_OF);
      compileType();
      break;
  case TK_IDENT://type ident
      eat(TK_IDENT);
      break;
  default :
    error(ERR_INVALIDTYPE, lookAhead->lineNo, lookAhead->colNo);
    break;
  }
}
开发者ID:duccuongict56bkhn,项目名称:CompilerLab,代码行数:24,代码来源:parser.c


示例11: __pyx_init_filenames

/* Implementation of cimport */

static struct PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC initcimport(void); /*proto*/
PyMODINIT_FUNC initcimport(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("cimport", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
  __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)Py_None); Py_INCREF(Py_None);
  __pyx_ptype_3pkg_4eggs_Eggs = __Pyx_ImportType("pkg.eggs", "Eggs", sizeof(struct __pyx_obj_3pkg_4eggs_Eggs)); if (!__pyx_ptype_3pkg_4eggs_Eggs) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; goto __pyx_L1;}

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":7 */
  eat(__pyx_v_7cimport_yummy);

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":8 */
  tons = 3.14;

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":9 */
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_pkg); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_eggs); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_ova, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Local/Projects/D/Pyrex/Source/Tests/8/cimport.pyx":10 */
  __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_3pkg_4eggs_Eggs), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_7cimport_fried));
  __pyx_v_7cimport_fried = ((struct __pyx_obj_3pkg_4eggs_Eggs *)__pyx_1);
  __pyx_1 = 0;
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("cimport");
}
开发者ID:jwilk,项目名称:Pyrex,代码行数:47,代码来源:cimport.c


示例12: game

void game(HGame *game)//전체게임함수
{
	int current_player = 0;
	while(true)
	{
		//인터페이스 : e(exit), b(잔고), h(키설명),save(저장).load
		
		//eat함수 
		eat();

		//상태갱신

		//점수산출score함수
		score();

		//났나? - 났을 때 고 혹은 스톱

		//스톱시 stop함수

		//턴 넘기기
		++current_player;
	}
}
开发者ID:Phryxia,项目名称:SSU_Hwatoo,代码行数:23,代码来源:Projectmain.c


示例13: while

void ImageEaterThread::run() {
    QImage* image;
    m_alive = true;
    while(m_alive) {
        m_mutexSleep.lock();
        m_condition.wait(&m_mutexSleep, m_rate);
        m_mutexSleep.unlock();
        image = eat();
        if (image != NULL && m_alive) {
            // TODO : when main window dies, m_renderTarget is deallocated
            // shared mutex ? (testing only for m_alive is not guaranteed)
            m_renderTarget->setPixmap(QPixmap::fromImage(*image));

            //allows for dynamic buffersize change and more robust when heavy lag
            if(m_numberImage < m_bufferSize) {
                m_condition.wakeAll();
            }

            delete image;
            emit imageEaten();
        }
    }
}
开发者ID:ciolben,项目名称:asmv,代码行数:23,代码来源:imageeaterthread.cpp


示例14: peek

QString GaduEmoticonParser::parseQuoted()
{
	QChar c = peek();
	if (c == '"')
	{
		eat();
		int quoteIndex = EmoticonLine.indexOf('"', Index);
		if (quoteIndex < 0)
			return getToIndex(EmoticonLine.length());
		else
			return getToIndex(quoteIndex);
	}

	int bracketIndex = EmoticonLine.indexOf(')', Index);
	int comaIndex = EmoticonLine.indexOf(',', Index);
	int endIndex = bracketIndex < 0
			? comaIndex
			: comaIndex < 0
					? bracketIndex
					: qMin(bracketIndex, comaIndex);

	return getToIndex(endIndex);
}
开发者ID:leewood,项目名称:kadu,代码行数:23,代码来源:gadu-emoticon-parser.cpp


示例15: _eat_item_on_floor

bool _eat_item_on_floor()
{
    // Don't steal stuff by eating them
    auto tile = get_tile_at(current_dungeon, player.pos.x, player.pos.y);
    if (tile->properties & TILE_PROP_SHOP)
    {
        return false;
    }

    std::vector<item_t*> food_on_ground;

    for (item_t* item : current_dungeon->items)
    {
        if (item->pos.x == player.pos.x && item->pos.y == player.pos.y && item->type == ITEM_TYPE_FOOD)
        {
            food_on_ground.push_back(item);
        }
    }

    for (item_t* food : food_on_ground)
    {
        if (yesno(format("There is a %s here. Eat it?", food->get_item_name().c_str()), true))
        {
            eat(&player, food);
            food->stacksize--;
            if (food->stacksize == 0)
            {
                remove_item(current_dungeon, food, true);
            }

            return true;
        }
    }

    return false;
}
开发者ID:smarmy,项目名称:HellRogue,代码行数:36,代码来源:game.cpp


示例16: do_dining

void do_dining(int dining_time, int eat_min, int eat_max,
	int think_min, int think_max)
{
	int think_time, eat_time, think_range, eat_range;
	if(signal(SIGUSR1,&start_dinner)==SIG_ERR)
	{
		printf("Cannot set signal handler! Aborting!\n");
		exit(1);
	}
	/** start random number generator */
	srand(time(0x0));
	think_range = think_max-think_min;
	think_time = (rand()%think_range)+think_min;
	eat_range = eat_max-eat_min;
	eat_time = (rand()%eat_range)+eat_min;
	/* wait for start signal! */
	while(start==0);
	printf("[GENIUS%d] Starting dinner...\n",which);
	/** dining philosopher here!!!! */
	while(dining_time>0)
	{
		/** start to think */
		think(think_time);
		/** try to get dining tools a.k.a. forks */
		if(starving()&&think_time>think_min) think_time--;
		else if(think_time<think_max) think_time++;
		/** start to eat */
		eat(eat_time,&dining_time);
		/** release dining tools a.k.a. forks - shouldn't we wash first? */
		burping();
	}
	fprintf(stderr,"[GENIUS%d] Finishing dinner...",which);
	fprintf(stderr," (Think=%d)(Starve=%d)(Attempt=%d)\n",
		total_think,total_starve,total_attempt);
	exit(0);
}
开发者ID:azman,项目名称:my1codeapp,代码行数:36,代码来源:dining.c


示例17: p_stmt

/**
==================== Stmt =============================================
   Grammar:
      stmt : loc '=' bool ';' | 'if' '(' bool ')' stmt | 'if' '(' bool ')' stmt 'else' stmt | 'while' '(' bool ')' stmt | 'do' stmt 'while' '(' bool ')' ';' | 'break' ';' | block | 'read' loc ';' | 'write' bool ';' 
*/
static TreeStmt p_stmt(void) {
   TreeStmt stmt = 0; // set null by default
   TokenCode code = curr()->code;
   // cases
   
   switch (code) {
      case TOK_id: {  //===== REDUCED TOK_loc
         TreeLoc l0loc = p_loc();
         eat('=');
         TreeBool l2bool = p_bool();
         eat(';');
         stmt = t_stmt_loc(l0loc, l2bool);
         break;
      }
      case TOK_if: {  
         eat(TOK_if);
         eat('(');
         TreeBool l2bool = p_bool();
         eat(')');
         TreeStmt l4stmt = p_stmt();
         stmt = t_stmt_if(l2bool, l4stmt);
         break;
      }
      case TOK_if: {  
         eat(TOK_if);
         eat('(');
         TreeBool l2bool = p_bool();
         eat(')');
         TreeStmt l4stmt = p_stmt();
         eat(TOK_else);
         TreeStmt l6stmt = p_stmt();
         stmt = t_stmt_if(l2bool, l4stmt, l6stmt);
         break;
      }
      case TOK_while: {  
         eat(TOK_while);
         eat('(');
         TreeBool l2bool = p_bool();
         eat(')');
         TreeStmt l4stmt = p_stmt();
         stmt = t_stmt_while(l2bool, l4stmt);
         break;
      }
      case TOK_do: {  
         eat(TOK_do);
         TreeStmt l1stmt = p_stmt();
         eat(TOK_while);
         eat('(');
         TreeBool l4bool = p_bool();
         eat(')');
         eat(';');
         stmt = t_stmt_do(l1stmt, l4bool);
         break;
      }
      case TOK_break: {  
         eat(TOK_break);
         eat(';');
         stmt = t_stmt_break();
         break;
      }
      case '{': {  //===== REDUCED TOK_block
         TreeBlock l0block = p_block();
         stmt = t_stmt_block(l0block);
         break;
      }
      case TOK_read: {  
         eat(TOK_read);
         TreeLoc l1loc = p_loc();
         eat(';');
         stmt = t_stmt_read(l1loc);
         break;
      }
      case TOK_write: {  
         eat(TOK_write);
         TreeBool l1bool = p_bool();
         eat(';');
         stmt = t_stmt_write(l1bool);
         break;
      }
      default:
         error_parse("stmt");
         break;
   }   

   
   return stmt;
}
开发者ID:elcritch,项目名称:trans,代码行数:92,代码来源:parser.c


示例18: main

int main(int argc, char* argv[])
{
    FILE *input = nullptr;
    if (argc > 1)
    {
        input = fopen(argv[1], "r");
        if (input == nullptr)
            return -1;
    }
    else
        return -1;
    std::cout.sync_with_stdio(false);

    // allocate the buffer
    char buffer[BUFFER_SIZE+1];
    char* line1 = nullptr;
    char* line2 = nullptr;
    char* brkt;
    size_t num_read = 0;


    num_read = fread(buffer, 1, BUFFER_SIZE, input);
    buffer[num_read] = '\0';
    auto book = new trading::booking<unsigned long>();

    auto process_line = [&book](char* line)
    {
        //std::cout << line << std::endl;
        auto message = book->parse_message(line);
        if (unlikely(message == nullptr))
            return;

        book->eat(message, std::cerr);
        book->print_mid(std::cerr);

        if ((++count) % 10 == 0)
            book->display(std::cerr);
        return;
    };


    while(true)
    {
        line1 = strtok_r(buffer, "\r\n", &brkt);
        int line1_size;
        while ((line2 = strtok_r(nullptr, "\r\n", &brkt)))
        {
            process_line(line1);
            line1 = line2;
        }
        if (likely(num_read == BUFFER_SIZE))
        {
            if (likely(buffer[BUFFER_SIZE-1] != 0))
            {
                line1_size= buffer + BUFFER_SIZE - line1;
                memmove(buffer, line1, line1_size);
                num_read = line1_size + 
                    fread(buffer + line1_size, 1, BUFFER_SIZE - line1_size, input);  
            }
            else {
                process_line(line1);
                num_read = fread(buffer, 1, BUFFER_SIZE, input);
            }
            buffer[num_read] = '\0';
        }
        else
        {
            // process last line
            process_line(line1);
            break;
        }
    }
    // finish work
    book->display(std::cout);
    delete book;
    fclose(input);
    //std::cout<< "Finish" << std::endl;

}
开发者ID:hurricane1026,项目名称:pricebooking,代码行数:79,代码来源:main.cpp


示例19: compileConstDecl

void compileConstDecl(void) {
  eat(TK_IDENT);
  eat(SB_EQ);
  compileConstant();
  eat(SB_SEMICOLON);
}
开发者ID:duccuongict56bkhn,项目名称:CompilerLab,代码行数:6,代码来源:parser.c


示例20: compileVarDecl

void compileVarDecl(void) {
  eat(TK_IDENT);
  eat(SB_COLON);
  compileType();
  eat(SB_SEMICOLON);
}
开发者ID:duccuongict56bkhn,项目名称:CompilerLab,代码行数:6,代码来源:parser.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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