示例#1
0
int			main(void)
{
	Form			paper("Piece of paper", 150, 150);
	Bureaucrat		barneyStinson("Barney Stinson", 2);

	std::cout << "Printing \"paper(\"Piece of paper\", 150, 150);\": " << paper;
	barneyStinson.signForm(paper);
	std::cout << "Printing \"paper(\"Piece of paper\", 150, 150);\": " << paper;

	Form			law("Law", 1, 1);
	std::cout << "Printing \"paper(\"Law\", 1, 1);\": " << law;
	barneyStinson.signForm(law);
	std::cout << "Printing \"paper(\"Law\", 1, 1);\": " << law;

	try {
		std::cout << "Trying to create \"something(\"something\", 151, 151);\"" << std::endl;
		Form			something("something", 151, 151);
	} catch (Form::GradeTooLowException & e) {
		std::cout << "Exception: " << e.what() << std::endl;
	}

	try {
		std::cout << "Trying to create \"something(\"something\", 0, 0);\"" << std::endl;
		Form			something("something", 0, 0);
	} catch (Form::GradeTooHighException & e) {
		std::cout << "Exception: " << e.what() << std::endl;
	}
}
示例#2
0
static int		something(char *path)
{
	char	*tmp;
	char	*line;
	int		fd;

	if(ft_strchr(path, '/'))
	{
		tmp = ft_strrchr(path, '/');
		tmp++;
	}
	else
		tmp = path;
	if ((fd = open(tmp, O_RDONLY)) != -1)
	{
		ft_putendl("\e[0;1mExisting file :\e[0m\n(A)bort, (R)ename, (O)verwrite ?");
		get_next_line(0, &line);
		if (line[0] == 'R')
		{
			ft_putendl("New name : ");
			get_next_line(0, &line);
			return (something(line));
		}
		else if (line[0] == 'O')
		{
			fd = open(tmp, O_TRUNC | O_WRONLY);
			return (fd);
		}
		else
		{
			close(fd);
			return (-1);
		}
	}
示例#3
0
文件: action.c 项目: HunterZ/larn
/*
    Performs the act of opening a chest.  

    Parameters:   x,y location of the chest to open.
    Assumptions:  cursors() has been called previously
*/
void act_open_chest(int x, int y)
{
    int i,k;

    k=rnd(101);
    if (k<40)
        {
        lprcat("\nThe chest explodes as you open it");
        i = rnd(10);  lastnum=281;  /* in case he dies */
        lprintf("\nYou suffer %d hit points damage!",(long)i);
        checkloss(i);
        switch(rnd(10)) /* see if he gets a curse */
            {
            case 1: c[ITCHING]+= rnd(1000)+100;
                    lprcat("\nYou feel an irritation spread over your skin!");
                    break;

            case 2: c[CLUMSINESS]+= rnd(1600)+200;
                    lprcat("\nYou begin to lose hand to eye coordination!");
                    break;

            case 3: c[HALFDAM]+= rnd(1600)+200;
                    lprcat("\nA sickness engulfs you!");    break;
            };
    item[x][y]=know[x][y]=0;    /* destroy the chest */
        if (rnd(100)<69) creategem(); /* gems from the chest */
    dropgold(rnd(110*iarg[playerx][playery]+200));
        for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
        }
    else
        lprcat("\nNothing happens");
    return;
}
示例#4
0
template<> ValueStack::T ValueStack::pop()
{
	if (!something()) { eprintf("Cannot pop from empty stack!\n"); eexit(); }
	T r = *(--_p);
	_p->Free();
	return r;
}
示例#5
0
 vector<vector<int>> pathSum(TreeNode* root, int sum) {
     vector<vector<int>> result;
     vector<int>         path;
     if (root) {
         something(result, path, 0, sum, root);
     }
     return result;
 }
示例#6
0
文件: sm_equiv3.c 项目: UIKit0/smatch
int func(void)
{

	red = something();
	if (x < 4)
		red = something();
	else if (x > 5)
		red = 0;

	blue = red;
	red = 0;
	if (!blue)
		return;
	__smatch_value("red");
	__smatch_value("blue");
	return 0;
}
示例#7
0
 void something(vector<vector<int>>& result,
                vector<int>&         path,
                int                  sum,
                int                  target,
                TreeNode            *node) {
     path.emplace_back(node->val);
     sum += node->val;
     if (!node->left && !node->right) {
         if (sum == target) {
             result.emplace_back(path);
         }
     }
     else {
         if (node->left) {
             something(result, path, sum, target, node->left);
         }
         if (node->right) {
             something(result, path, sum, target, node->right);
         }
     }
     path.pop_back();
 }
示例#8
0
文件: memopt-8.c 项目: 0day-ci/gcc
int f()
{
  int *p;

  __transaction_atomic {
    p = malloc (sizeof (*p) * 100);
    escape (p);

    /* This should be instrumented because P escapes.  */
    p[5] = 123;

    if (something())
      __transaction_cancel;
  }
  return p[5];
}
示例#9
0
int f()
{
  int *p;

  p = malloc (sizeof (*p) * 100);

  __transaction_atomic {
    /* p[5] is thread private, but not transaction local since the
       malloc is outside of the transaction.  We can use the logging
       functions for this.  */
    p[5] = 123;

    if (something())
      __transaction_cancel;
  }
  return p[5];
}
示例#10
0
int f()
{
  int *p;

  p = malloc (sizeof (*p) * 100);
  foo(p[5]);

  __transaction_atomic {
    /* p[5] is thread private, however the SSA_NAME that holds the
       address dominates the entire transaction (transaction
       invariant) so we can use a save/restore pair.  */
    p[5] = 123;

    if (something())
      __transaction_cancel;
  }
  return p[5];
}
示例#11
0
文件: usetime1.cpp 项目: lukelino/VS
int main()
{
	Time planning;
	Time coding(2, 40);
	Time fixing(5, 55);
	Time total;

	std::cout << "planning: ";
	planning.Show();
	std::cout << "coding: ";
	coding.Show();
	std::cout << "fixing: ";
	fixing.Show();
	std::cout << "total: ";
	total = coding + fixing;
	total.Show();

	Time morefixing(3, 28);
	std::cout << "more fixing: ";
	morefixing.Show();

	std::cout << "total: ";
	total = total + morefixing;
	total.Show();

	std::cout << "operator+():\n";
	total = total.operator+(morefixing);
	total.Show();
	std::cout << total;	//przeci¹¿ona wersja '<<' zwracaj¹ca referencjê do ostream

	std::ofstream fout;
	fout.open("tst.txt");
	std::cout << "overloading <<:\n";
	operator<<(std::cout, total);	//lub tak: std::cout << total;
	fout << total;					//lub tak: operator<<(fout, total);
	//fout.close();

	Time something(2, 40);
	Time res;
	res = operator*(2.5, something);
	operator<<(fout, res);
	fout.close();
	return 0;
}
示例#12
0
/* Assert macros that you can use in your test functions. "cmp" is a
 * comparison operator, one of ==, !=, <, >, <=, >=.
 *
 *  g_assert( boolean_expression )
 *  g_assert_not_reached()
 *  g_assert_cmpstr( gchar *s1, cmp, gchar *s2 )
 *  g_assert_cmpint( int s1, cmp, int s2 )
 *  g_assert_cmpuint( unsigned int s1, cmp, unsigned int s2 )
 *  g_assert_cmphex( unsigned int s1, cmp, unsigned int s2 )
 *  g_assert_cmpfloat( double s1, cmp, double s2 )
 *  g_assert_no_error( GError *err )
 *  g_assert_error( GError *err, GQuark domain, gint code )
 *
 * You can also emit arbitrary messages into the test report with
 *  g_test_message( const char* format, ... )
 */
void
test_suite_module1 (void)
{
    Datatype data = something();
    GNC_TEST_ADD_FUNC (suitename, "Test Name 1", test_function);
    {
        gchar *testpath = g_strdup_printf ("%s/Test Name 2", suitename);
        g_test_add_data_func( suitename, (gconstpointer)(&data),
                              test_function_with_data );
        g_free (testpath);
    }
    GNC_TEST_ADD (suitename, "Test Name 3", Fixture, data, setup,
                  test_function_with_fixture, teardown);
    /* Other conditionals are g_test_quick(), g_test_slow(), and
     * g_test_thorough() */
    if ( g_test_perf() )
    {
        GNC_TEST_ADD_FUNC (suitename, "Test Name 4", test_performance_func);
    }
}
示例#13
0
void CEnv::SetData(Rcpp::IntegerMatrix x_, Rcpp::IntegerMatrix mcz_) {
	int J = x_.nrow();
	int n = x_.ncol();
	int nZeroMC = mcz_.ncol();
	if (mcz_.nrow() != J) { // no mcz
		nZeroMC = 0; 
	}
  	
	intvec x = Rcpp::as<intvec>(x_);
	intvec mcz = Rcpp::as<intvec>(mcz_);
  
	Rcpp::List something(x_.attr("levels"));
	intvec levels(something.size());
	for (unsigned int i = 0; i < levels.size(); i++) {
		SEXP exp = something[i];
		Rcpp::CharacterVector v(exp);
		levels[i] = v.size();
		//Rprintf( "%d\n", levels[i]) ;
	}
	SetData(x, J, n, mcz, nZeroMC, levels);	
}
void f()
{
	cout << something(
		arg);
	cout
	        << "something";
	cout <<
	        "something";

	RLOGD(m_log)
	        << "WriteReqSize()";

	RLOGD(m_log) <<
	        base::sprintfT(
		"something %u ",
		m_pendingAccepts);

	RLOGDD(m_log) << sprintfT(
		"something id=%u",
		newSocket->GetId());
}
void test() {
  D obj;
  something(obj.fixbin,   // expected-error {{did you mean 'fizbin'?}}
            obj.toobat);  // expected-error {{did you mean 'toobad'?}}
  something(obj.toobat,   // expected-error {{did you mean 'foobar'?}}
            obj.fixbin);  // expected-error {{did you mean 'roxbin'?}}
  something(obj.fixbin,   // expected-error {{did you mean 'fizbin'?}}
            obj.fixbin);  // expected-error {{did you mean 'roxbin'?}}
  something(obj.toobat,   // expected-error {{did you mean 'foobar'?}}
            obj.toobat);  // expected-error {{did you mean 'toobad'?}}
  // Both members could be corrected to methods, but that isn't valid.
  something(obj.boohoo,   // expected-error-re {{no member named 'boohoo' in 'D'{{$}}}}
            obj.foxbox);  // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
  // The first argument has a usable correction but the second doesn't.
  something(obj.boobar,   // expected-error-re {{no member named 'boobar' in 'D'{{$}}}}
            obj.foxbox);  // expected-error-re {{no member named 'foxbox' in 'D'{{$}}}}
}
示例#16
0
int main(void) {
    something();
    //printf("%s\n");
}
示例#17
0
template<> ValueStack::T ValueStack::peek()
{
	if (!something()) { eprintf("Cannot peek in empty stack!\n"); eexit(); }
	return *(_p-1);
}
示例#18
0
/*
	function to read a scroll
 */
void read_scroll(int typ)
{
	int i,j;
	if (typ<0 || typ>=MAXSCROLL) 
		return;  /* be sure we are within bounds */
	if (scrollknown[typ] == 0) 
		scrollknown[typ] = 1;
	lprintf("\nYou read a scroll of %s.", &(scrollname[typ][1]));

	switch(typ) {
	case SENCHANTARM:
		enchantarmor(ENCH_SCROLL);
		return;

	case SENCHANTWEAP:	
		enchweapon(ENCH_SCROLL);
		return;

	case SENLIGHTEN:
		lflush();
		yh = min(playery+7,MAXY);	
		xh = min(playerx+25,MAXX);
		yl = max(playery-7,0);		
		xl = max(playerx-25,0);
		for (i=yl; i<yh; i++)
			for (j=xl; j<xh; j++)
				know[j][i]=1;
		nap(2000);	
		draws(xl,xh,yl,yh);	
		return;

	case SBLANK:
		return;

	case SCREATEMONST:
		createmonster(makemonst(level+1));  
		return;

	case SCREATEITEM:
		something(playerx, playery, level);	
		return;

	case SAGGMONST:
		c[AGGRAVATE]+=800;
		return;

	case STIMEWARP:
		/*
		 *  This code is slightly wrong in that, if gtime is small and
		 *  we can't go back by the required number of mobuls, it's
		 *  still reported that we did.  I don't think this is
		 *  critical -- dmr
		 */
		 i = (rnd(1000) - 850)/100;
		 if (i==0) i=1;

		gtime += 100*i;
		if (gtime < 0) gtime = 0;

		lprintf("\nYou go %sward in time by %d mobul%s", (i<0)?"back":"for",
				(i<0)?-i:i, i==1?"":"s");

		adjusttime((long)(i*100));/* adjust time for time warping */
		return;

	case STELEPORT:
		oteleport(0);	  
		return;

	case SAWARENESS:
		c[AWARENESS] += 1800;  
		return;

	case SHASTEMONST:
		c[HASTEMONST] += rnd(55)+12; 
		lprintf("  You feel nervous.");
		return;

	case SMONSTHEAL:
		for (i=0; i<MAXY; i++)  
			for (j=0; j<MAXX; j++)
				if (mitem[j][i].mon)
					hitp[j][i] = monster[mitem[j][i].mon].hitpoints;
		lprintf("  You feel uneasy.");
		return;

	case SSPIRITPROT:
		c[SPIRITPRO] += 300 + rnd(200); 
		bottomline(); 
		return;

	case SUNDEADPROT:
		c[UNDEADPRO] += 300 + rnd(200); 
		bottomline(); 
		return;

	case SSTEALTH:
		c[STEALTH] += 250 + rnd(250);  
		bottomline(); 
		return;

	case SMAGICMAP:
		lflush();
		for (i=0; i<MAXY; i++) 
			for (j=0; j<MAXX; j++)  
				know[j][i]=1;
		nap(2000);	
		draws(0,MAXX,0,MAXY);	
		return;

	case SHOLDMONST:
		c[HOLDMONST] += 30; 
		bottomline(); 
		return;

	case SGEMPERFECT:
		for (i=0; i<IVENSIZE; i++)
			switch(iven[i]) {
			case ODIAMOND:	
			case ORUBY:
			case OEMERALD:	
			case OSAPPHIRE:
				j = ivenarg[i];  
				j *= 2;  
				if (j <= 0 && ivenarg[i]) 
					j=2550;
				ivenarg[i] = j;	
				break;
			}
		break;

	case SSPELLEXT:
		for (i=0; i<11; i++)
			c[exten[i]] <<= 1;
		break;

	case SIDENTIFY:
		for (i=0; i<IVENSIZE; i++)
		{
			if (iven[i]==OPOTION)  
				potionknown[ivenarg[i]] = 1;
			if (iven[i]==OSCROLL)  
				scrollknown[ivenarg[i]] = 1;
		}
		break;

	case SREMCURSE:
		removecurse();
		break;

	case SANNIHILATE:
		annihilate();
		break;

	case SPULVERIZE:
		godirect(22,150,"The ray hits the %s.",0,' ');
		break;

	case SLIFEPROT:
		c[LIFEPROT]++;
		break;
	};
}
示例#19
0
/*
 *	******
 *	OCHEST
 *	******
 *
 */
void ochest()
{
	int i,k;

	lprcat("\nDo you (t) take it, (o) try to open it"); 
	iopts();
	while (1) {
		while (1) switch(getcharacter()) {
		case 'o':	
			lprcat(" open it.");  
			k=rnd(101);
			if (k<40) {
				lprcat("\nThe chest explodes as you open it."); 
				beep();
				i = rnd(10);
				if (i > c[HP]) i = c[HP];
				lastnum=281;  /* in case he dies */
				lprintf("\nYou suffer %d hit point%s damage!", (long)i,
						i==1?"":"s");
				checkloss(i);
				switch(rnd(10))	{
				case 1:	
					c[ITCHING]+= rnd(1000)+100;
					lprcat("\nYou feel an irritation spread over your skin!");
					beep();
					break;

				case 2:	
					c[CLUMSINESS]+= rnd(1600)+200;
					lprcat("\nYou begin to lose hand-eye co-ordination!");
					beep();
					break;

				case 3:	
					c[HALFDAM]+= rnd(1600)+200;
					lprcat("\nYou suddenly feel sick and BARF all over your "
						   "shoes!");
					beep();
					break;
				};
				item[playerx][playery]=know[playerx][playery]=0;
				if (rnd(100)<69) 
					creategem(); /* gems from the chest */
				dropgold(rnd(110*iarg[playerx][playery]+200));
				for (i=0; i<rnd(4); i++) 
					something(playerx, playery, iarg[playerx][playery]+2);
			}
			else lprcat("\nNothing happens.");
			return;

		case 't':	
			lprcat(" take");
			if (take(OCHEST,iarg[playerx][playery])==0)
				item[playerx][playery]=know[playerx][playery]=0;
			return;

		case 'i':
		case ESC: 
			ignore(); 
			return;
		};
	} /* NOTREACHED */
}
示例#20
0
Vec3f Force::getFeaturedForce() const{
	Vec3f something(0, 0, 50);
	return something;
}
示例#21
0
文件: main.cpp 项目: CCJY/coliru
int main()
{
    something(type1{});
    something(type2{});
}
示例#22
0
文件: object.c 项目: davidpeng/ularn
/* =============================================================================
 * FUNCTION: oopenchest
 */
void oopenchest(void)
{
  int i;
  int k;

  if (item[playerx][playery] != OCHEST)
  {
    return;
  }

  k = rnd(101);
  if (k < 40)
  {
    Print("The chest explodes as you open it.");
    UlarnBeep();
    i = rnd(10);
    if (i > c[HP]) i = c[HP];

    Printf("You suffer %d hit point%s damage!", (long)i, plural(i));
    losehp(DIED_EXPLODING_CHEST, i);
    UpdateStatus();

    switch (rnd(10))
    {
      case 1:
        c[ITCHING]+= rnd(1000)+100;
        Print("You feel an irritation spread over your skin!");
        UlarnBeep();
        break;

      case 2:
        c[CLUMSINESS]+= rnd(1600)+200;
        Print("You begin to lose hand-eye co-ordination!");
        UlarnBeep();
        break;

      case 3:
        c[HALFDAM]+= rnd(1600)+200;
        Print("You suddenly feel sick and BARF all over your shoes!");
        UlarnBeep();
        break;
    }

    /* Remove the chest */
    item[playerx][playery] = ONOTHING;

    /* create the items in the chest */
    if (rnd(100)<69)
    {
      /* gems from the chest */
      creategem();
    }

    dropgold(rnd(110 * iarg[playerx][playery] + 200));

    for (i=0; i<rnd(4); i++)
    {
      something(playerx, playery, iarg[playerx][playery]+2);
    }
  }
  else
  {
    Print("Nothing happens.");
  }
}
示例#23
0
int main()
{
  something(-1);
  return 0;
}
示例#24
0
文件: main.cpp 项目: CCJY/coliru
int main () {
    
    something( breaking );
    
}
示例#25
0
template<> CharacterStack::T CharacterStack::pop()
{
	if (!something()) { eprintf("Cannot pop from empty stack!\n"); eexit(); }
	T r = *(--_p);
	return r;
}
示例#26
0
void server::newConnection()
{
qDebug()<<"lol got connected";
soc=ser->nextPendingConnection();
connect(soc,SIGNAL(readyRead()),this,SLOT(something()));
}
int main() {
  if (constexpr long v = something()) {}
  if (static long v = something()) { } // { dg-error "decl-specifier invalid" }
}