示例#1
0
ElliPoint *sum(ElliPoint *p,ElliPoint *q,int a,int base) {
	ElliPoint *o,*r;
	o = ElliInfty();
	r = star(o,star(p,q,a,base),a,base);
	free(o);
	return r;
}
示例#2
0
文件: test.c 项目: gautamkmr/Code
 void star(int i) {
if (i > 1) {
star(i/2);
star(i/2);
}
printf( "hello\n");   
  }
示例#3
0
 void main()
 {
  int i,j;
  for (i=1;i<=4;i++)
    { for(j=1;j<=2*i-1;j++) printf (" ");
      star();
     }
  for (i=3;i>=1;i--)
    { for(j=1;j<=2*i-1;j++) printf (" ");
      star();
     }
  }
示例#4
0
文件: prob0096.cpp 项目: jhnaldo/toy
void print(int n, bool upper){
    if (n == 1) {
        printf("*\n");
    }else{
        if (upper){
            print(n-1, upper);
            star(n);
        }else{
            star(n);
            print(n-1, upper);
        }
    }
}
示例#5
0
文件: prob0079.cpp 项目: jhnaldo/toy
int main(){
    int n, i;
    scanf("%d", &n);
    for (i = 1; i <= n; i++){
        star(i);
        printf("\n");
    }
    for (i = n-1; i >= 1; i--){
        star(i);
        printf("\n");
    }
    return 0;
}
示例#6
0
//static int crossHatch ( int *masks )
static int crossHatch ( short **pmasks )

{
   int	progress = 0;
   //int	solutions [9];
   short	solutions [9];
   short	*psolutions [9];
   int	k;
   for ( k = 0; k < 9; k++ ) {
   	psolutions [k] = &solutions[k];
   }
   int	i;

#if	defined(DEBUG)
   //fprintf ( logFile, "crossHatch ( %04X ) {\n", (unsigned int)masks );
   fprintf ( logFile, "crossHatch ( %p ) {\n", pmasks );
   fflush ( logFile );
#endif

   for ( i = 0; i < 9; ++i ) {

	int	j;

	//solutions [i] = masks [i];
	solutions [i] = star(pmasks [i]);
	IFT(psolutions [i], pmasks [i]);

	//for ( j = 0; j < 9; ++j ) if ( j != i ) solutions [i] &= ~masks [j];
	for ( j = 0; j < 9; ++j ) {
		if ( j != i ) {
			solutions [i] &= ~(star(pmasks [j]));
			IFT(psolutions [i], pmasks [j]);
		}
	}
		
   }

   for ( i = 0; i < 9; ++i ) {

	//if ( masks [i] = bit2digit ( solutions [i] ) ) ++progress;
	if ( STAR(pmasks [i]) = bit2digit ( solutions [i] ) ) ++progress;
	IFT(pmasks [i], psolutions [i]);
   }

#if	defined(DEBUG)
   fprintf ( logFile, "} = %d /* crossHatch () */\n", progress );
   fflush ( logFile );
#endif

   return ( progress );
}
示例#7
0
void MyModel_Pixels::initialise()
{
    for(size_t i=0; i<ni; ++i)
        y[i] = y_max - (i + 0.5)*dy;

    for(size_t j=0; j<nj; ++j)
        x[j] = x_min + (j + 0.5)*dx;

    double rsq;

    double limb_darkening_coefficient = 1.0;

    // Argh column-major order
    // Star image
    double tot = 0.0;
    for(size_t j=0; j<nj; ++j)
    {
        for(size_t i=0; i<ni; ++i)
        {
            rsq = x[j]*x[j] + y[i]*y[i];
            if(rsq < 1.0)
            {
                star(i, j) = 1.0 -
                    limb_darkening_coefficient*(1.0 - sqrt(1.0 - rsq));
            }
            else
                star(i, j) = 0.0;
            tot += star(i, j);
        }
    }
    for(size_t j=0; j<nj; ++j)
        for(size_t i=0; i<ni; ++i)
            star(i, j) /= tot;

    arma::mat star2 = star;
    int m, n;
    for(int i=0; i<(int)ni; i++)
    {
        m = DNest4::mod(i - (int)ni/2, (int)ni);
        for(int j=0; j<(int)nj; j++)
        {
            n = DNest4::mod(j - (int)nj/2, (int)nj);
            star2(m, n) = star(i, j);
        }
    }

    fft_of_star = arma::fft2(star2);
}
示例#8
0
int main( int argc, char *argv[] )
{
    int center = -1, minsize = -1, maxsize = -1, repeats = -1;
    int c;

    MPI_Init( &argc, &argv );

    while( ( c = getopt( argc, argv, "c:i:a:r:" ) ) != -1 ) {
	switch( c ) {
	case 'c':
	    if( sscanf( optarg, "%d", &center ) != 1 )
		exit( EXIT_FAILURE );
	    break;
	case 'i':
	    if( sscanf( optarg, "%d", &minsize ) != 1 )
		exit( EXIT_FAILURE );
	    break;
	case 'a':
	    if( sscanf( optarg, "%d", &maxsize ) != 1 )
		exit( EXIT_FAILURE );
	    break;
	case 'r':
	    if( sscanf( optarg, "%d", &repeats ) != 1 )
		exit( EXIT_FAILURE );
	    break;
	}
    }

    star( center, minsize, maxsize, repeats );

    MPI_Finalize();
    
    exit( EXIT_SUCCESS );
}
示例#9
0
文件: Gender.cpp 项目: sleimanf/aibot
StringPimpl Gender::getString() const
throw(InternalProgrammerErrorException &)
{
    LOG_BOT_METHOD("StringPimpl Gender::getString() const");

    try
    {
        if(m_pimpl->m_atomic)
        {
            logging("This is an atomic element shortcut");
            Star star(m_pimpl->m_builder);
            StringPimpl returnString = star.getString();
            return m_pimpl->m_builder.genderSubstitute(returnString);
        }
        else
        {
            return m_pimpl->m_builder.genderSubstitute(InnerTemplateListImpl::getString());
        }
    }
    catch(Exception &e)
    {
        logging(String("Fatal exception occured:") + e.what());
        return StringPimpl();
    }
}
示例#10
0
void QStarFrame::drawstars()
{
    QString starpath = KStandardDirs::locate("data", "knewstuff/pics/ghns_star.png");
    QString graystarpath = KStandardDirs::locate("data", "knewstuff/pics/ghns_star_gray.png");

    QPixmap star(starpath);
    QPixmap graystar(graystarpath);

    int wpixels = (int)(width() * (float)m_rating / 100.0);

    QPainter p;
    p.begin(this);
    int w = star.width();
    for (int i = 0; i < wpixels; i += star.width()) {
        w = wpixels - i;
        if (w > star.width()) w = star.width();
        p.drawPixmap(i, 0, star, 0, 0, w, -1);
    }
    p.drawPixmap(wpixels, 0, graystar, w, 0, graystar.width() - w, -1);
    wpixels += graystar.width() - w;
    for (int i = wpixels; i < width(); i += graystar.width()) {
        w = width() - i;
        if (w > graystar.width()) w = graystar.width();
        p.drawPixmap(i, 0, graystar, 0, 0, w, -1);
    }
    p.end();
}
示例#11
0
int			match(char *tested, char *word)
{
	if (*word == '\0' && *tested == '\0')
		return (1);
	if (*word == 0x5c)
	{
		if (*(word + 1) != *tested)
			return (0);
		else
			return (match(tested + 1, word + 2));
	}
	if (*word == '*' || *word == '?' || *word == '[')
	{
		if (*word == '*')
			return (star(tested, word));
		else if (*word == '?')
			return (question_mark(tested, word));
		else if (*word == '[')
			return (test_bracket(tested, word));
	}
	else if (*word == *tested)
		return (match(tested + 1, word + 1));
	else
		return (0);
	return (1);
}
示例#12
0
// -----------------------------------------------------------------
// Main program prints out coefficients and other pertinent information
int main(int argc, char* argv[]) {
  int i, order;
  double alpha, epsilon, delta, err, c[NMAX + 1];

  if (argc != 3) {
    printf("Usage: %s epsilon delta\n", argv[0]);
    return -1;
  }

  epsilon = atof(argv[1]);
  delta = atof(argv[2]);
  squareroot(delta, epsilon, c, &order, &err);

//  for(i = 0; i < 5001;i++) {
//    double x = 2. * i / 5000. - 1.;
//    printf("%e %e SIGN\n", x, h(x));
//  }

  printf("order = %d;\n", order);
  printf("epsilon = %.8g;\n", epsilon);
  printf("err = %.8g;\n\n", err);
  for (alpha = 0; alpha <= 3.0; alpha += 0.5) {
    printf("star(%.2g) = %.8g;\n", alpha,
           star(delta, epsilon, order, c, alpha));
  }
  printf("\n");
  for (i = 0; i <= order; i++)
    printf("coeffs[%d] = %.16g;\n", i, c[i]);

  return 0;
}
示例#13
0
//static void updateBlockMasks ( PUZZLE *puzzle, int row, int column, int entry )
static void updateBlockMasks ( PUZZLE *puzzle, int row, int column, short *pentry )

{
   int	rowMax = row + 3 - ( row % 3 );
   int	columnMax = column + 3 - ( column % 3 );
   //int	mask = ~digit2bit ( entry );
   short	mask = ~digit2bit ( star(pentry) );
   short	*pmask = &mask;
   IFT(pmask, pentry);

#if	defined(DEBUG)
   //fprintf ( logFile, "updateBlockMasks ( %p, %d, %d, %d ) {\n", puzzle, row,
   fprintf ( logFile, "updateBlockMasks ( %p, %d, %d, %p ) {\n", puzzle, row,
								column, pentry );
   fflush ( logFile );
#endif

   for ( row = rowMax - 3; row < rowMax; ++row ) {

	for ( column = columnMax - 3; column < columnMax; ++column ) {

		puzzle->masks [row][column] &= mask;
		IFT(puzzle->pmasks [row][column], pmask);
	}
   }

#if	defined(DEBUG)
   fprintf ( logFile, "} /* updateBlockMasks () */\n" );
   fflush ( logFile );
#endif
}
示例#14
0
//static void updateColumnMasks ( PUZZLE *puzzle, int column, int entry )
static void updateColumnMasks ( PUZZLE *puzzle, int column, short *pentry )

{
   int	row;
   //int	mask = ~digit2bit ( entry );
   short	mask = ~digit2bit ( star(pentry) );
   short	*pmask = &mask;
   IFT(pmask, pentry);

#if	defined(DEBUG)
   //fprintf ( logFile, "updateColumnMasks ( %p, %d, %d ) {\n", puzzle, column,
   fprintf ( logFile, "updateColumnMasks ( %p, %d, %p ) {\n", puzzle, column,
									pentry );
   fflush ( logFile );
#endif

   for ( row = 0; row < 9; ++row ) {

	puzzle->masks [row][column] &= mask;
	IFT(puzzle->pmasks [row][column], pmask);
   }

#if	defined(DEBUG)
   fprintf ( logFile, "} /* updateColumnMasks () */\n" );
   fflush ( logFile );
#endif
}
示例#15
0
int main(int num)
{

  star(num);
  
  return 0;
}
示例#16
0
//**************************
//Description : Draw the menu
//Parameters : None
//Return Value : None
//Note : None
//**************************
void CMenu::DrawMenu()
{
    // We first fill the entire screen with black
    m_RenderWindow->SetBackgroundColor(sf::Color(0,0,0));

    //we draw the background
    m_SpriteBackground->Draw();

    //we draw the title at the top of the screen an to the center
    m_RenderWindow->Draw(m_Title);

    //we draw the options
    for (int i = 0; i < NUMBER_OPTION_MENU; i++)
    {
        if ( i == m_iOptionSelected )
        {
            sf::String star("*");
            star.SetFont(*(m_SFMLManager->GetFont()));
            star.SetColor(sf::Color(255,0,0));
            star.Move(10, 300 + i * 40);

            m_RenderWindow->Draw(star);
        }

        m_RenderWindow->Draw(m_Menu[i]);
    }

    //We display the screen
    m_RenderWindow->Display();
}
示例#17
0
            pilo::core::net::ipv4_mask ipv4_mask::build(const char* ipAddress)
            {
                char buf[32];
                pilo::core::string::string_util::copy(buf, sizeof(buf), ipAddress, MC_INVALID_SIZE);

                ipv4_mask ipMask = { 0xffffffff, 0xffffffff };

                char* abcd[4];
                size_t n = pilo::core::string::string_util::split(buf, '.', abcd, 4);
                if (n != 4)
                {
                    return ipMask;
                }

                pilo::core::string::fixed_astring<16> star("*");
                pilo::core::string::fixed_astring<16> sa = abcd[0];
                pilo::core::string::fixed_astring<16> sb = abcd[1];
                pilo::core::string::fixed_astring<16> sc = abcd[2];
                pilo::core::string::fixed_astring<16> sd = abcd[3];

                pilo::u32_t a = sa == star ? 0 : pilo::core::string::string_util::cstr_to_int32(sa.c_str());
                pilo::u32_t b = sb == star ? 0 : pilo::core::string::string_util::cstr_to_int32(sb.c_str());
                pilo::u32_t c = sc == star ? 0 : pilo::core::string::string_util::cstr_to_int32(sc.c_str());
                pilo::u32_t d = sd == star ? 0 : pilo::core::string::string_util::cstr_to_int32(sd.c_str());

                unsigned int ma = sa == star ? 0 : 255;
                unsigned int mb = sb == star ? 0 : 255;
                unsigned int mc = sc == star ? 0 : 255;
                unsigned int md = sd == star ? 0 : 255;

                ipMask.m_mask = MF_MAKE_IPV4_ADDRESS(ma, mb, mc, md);
                ipMask.m_target = MF_MAKE_IPV4_ADDRESS(a, b, c, d);

                return ipMask;
            }
void display()
{
  glClear(GL_COLOR_BUFFER_BIT);
  glLoadIdentity();
  star();
  glutSwapBuffers();
}
示例#19
0
SemilinSetExp SemilinSetExp::star() const {
  SemilinSetExp result = SemilinSetExp::one();
  for (auto &ls : val) {
    result *= SemilinSetExp(star(ls));
  }
  return result;
}
示例#20
0
文件: q1.c 项目: kieranhogan13/C
main()
{
    printf("See function below:\n\n");
    /*Call function star*/
    star();
    printf("\n\nSee function above:");
    getchar();
}
示例#21
0
文件: prob0096.cpp 项目: jhnaldo/toy
void star(int n){
    if (n == 1) {
        printf("*\n");
    }else{
        printf("*");
        star(n-1);
    }
}
示例#22
0
int main(void) {
  grid g("grid1.sph");
  cloud star("star1.sph");
  star.transfer_mass2grid(g);
  g.set_densities_and_pressures();
  star.evolve(g);
  return 1;
}
示例#23
0
void RigidBodySolver::performEulerIntegration(float dt){
	body->v += 1/body->mass*dt*body->force;
	body->x += dt*body->v;
	body->R += dt*star(body->omega)*body->R;
	body->Iinv = body->R*body->Ibodyinv*body->R.transposed();
	body->L += dt*body->torque;
	body->omega = body->Iinv*body->L;
}
示例#24
0
void StarField::initialise()
{
	if (starField.empty())
	{
		for (int i = 0; i < smallCount; i++)
		{
			if (i < mediumCount)
			{
				Star star(RandomGen().getRand(playerRef->getPlayerX() + 30,
					playerRef->getPlayerX() - 30),
					RandomGen().getRand(playerRef->getPlayerY() + 18,
					playerRef->getPlayerY() - 18),
					MED_STAR_PARALLAX_SPEED,
					MED_STAR_PARALLAX_SPEED,
					MED_STAR_BRIGHTNESS);
				starField.push_back(star);
			}
			if (i < largeCount)
			{
				Star star(RandomGen().getRand(playerRef->getPlayerX() + 30,
					playerRef->getPlayerX() - 30),
					RandomGen().getRand(playerRef->getPlayerY() + 18,
					playerRef->getPlayerY() - 18),
					LARGE_STAR_PARALLAX_SPEED,
					LARGE_STAR_PARALLAX_SPEED,
					HIGH_STAR_BRIGHTNESS);
				starField.push_back(star);
			}
			Star star(RandomGen().getRand(playerRef->getPlayerX() + 30,
				playerRef->getPlayerX() - 30),
				RandomGen().getRand(playerRef->getPlayerY() + 18,
				playerRef->getPlayerY() - 18),
				SMALL_STAR_PARALLAX_SPEED,
				SMALL_STAR_PARALLAX_SPEED,
				LOW_STAR_BRIGHTNESS);
			starField.push_back(star);
		}
	}
	else
	{
		starField.clear();
		initialise();
	}
}
示例#25
0
void StarField::initialise(double xPos, double yPos)
{
	if (starField.empty())
	{
		for (int i = 0; i < smallCount; i++)
		{
			if (i < mediumCount)
			{
				Star star(RandomGen().getRand(xPos + 30,
					xPos - 30),
					RandomGen().getRand(yPos + 18,
					yPos - 18),
					MED_STAR_PARALLAX_SPEED,
					MED_STAR_PARALLAX_SPEED,
					MED_STAR_BRIGHTNESS);
				starField.push_back(star);
			}
			if (i < largeCount)
			{
				Star star(RandomGen().getRand(xPos + 30,
					xPos - 30),
					RandomGen().getRand(yPos + 18,
					yPos - 18),
					LARGE_STAR_PARALLAX_SPEED,
					LARGE_STAR_PARALLAX_SPEED,
					HIGH_STAR_BRIGHTNESS);
				starField.push_back(star);
			}
			Star star(RandomGen().getRand(xPos + 30,
				xPos - 30),
				RandomGen().getRand(yPos + 18,
				yPos - 18),
				SMALL_STAR_PARALLAX_SPEED,
				SMALL_STAR_PARALLAX_SPEED,
				LOW_STAR_BRIGHTNESS);
			starField.push_back(star);
		}
	}
	else
	{
		starField.clear();
		initialise();
	}
}
示例#26
0
//static int makeEntry ( PUZZLE *puzzle, int i, int j, int entry )
static int makeEntry ( PUZZLE *puzzle, int i, int j, short *pentry )

{
   int	status = 0;
   //int	bit = digit2bit ( entry );
   short	bit = digit2bit ( star(pentry) );
   short	*pbit = &bit;
   IFT(pbit, pentry);

#if	defined(DEBUG)
   //fprintf ( logFile, "makeEntry ( %p, %d, %d, %d ) {\n", puzzle, i, j, entry );
   fprintf ( logFile, "makeEntry ( %p, %d, %d, %p ) {\n", puzzle, i, j, pentry );
   fflush ( logFile );
#endif

   /* Is this a legal entry? */
   if ( puzzle->rowMasks [i] & puzzle->columnMasks [j]
				& puzzle->blockMasks [i/3][j/3] & bit ) {
	status = 1;
	puzzle->rowMasks [i] ^= bit;
	puzzle->columnMasks [j] ^= bit;
	puzzle->blockMasks [i/3][j/3] ^= bit;
	//puzzle->grid [i][j] = entry;
	puzzle->grid [i][j] = star(pentry);
	puzzle->masks [i][j] = 0;

	IFT(puzzle->prowMasks [i], pbit);
	IFT(puzzle->pcolumnMasks [j], pbit);
	IFT(puzzle->pblockMasks [i/3][j/3], pbit);
	IFT(puzzle->pgrid [i][j], pentry);

	if ( puzzle->history ) pushHistory ( puzzle->history, i, j );
   }

#if	defined(DEBUG)
   fprintf ( logFile, "} = %d /* makeEntry () */\n", status );
   fflush ( logFile );
#endif

   return ( status );
}
示例#27
0
文件: fractals.c 项目: ahaggan/ArtC
//Called from interface.c
void generate_fractal(Draw *fractal, SDL_Win *window, int i) 
{
    if(strcmp(fractal->type[i], "sierpinski") == 0){
        sierpinski(fractal, window, i);
    }
    else if(strcmp(fractal->type[i], "tree") == 0){
        tree(fractal, window, i);
    }
    else if(strcmp(fractal->type[i], "star") == 0){
        star(fractal, window, i);
    }
}
示例#28
0
void StarsPlugin::loadStars()
{
    //mDebug() << Q_FUNC_INFO;
    // Load star data
    m_stars.clear();

    QFile starFile( MarbleDirs::path( "stars/stars.dat" ) );
    starFile.open( QIODevice::ReadOnly );
    QDataStream in( &starFile );

    // Read and check the header
    quint32 magic;
    in >> magic;
    if ( magic != 0x73746172 ) {
        return;
    }

    // Read the version
    qint32 version;
    in >> version;
    if ( version > 002 ) {
        mDebug() << "stars.dat: file too new.";
        return;
    }
    int maxid = 0;
    int id = 0;
    int starIndex = 0;
    double ra;
    double de;
    double mag;

    mDebug() << "Star Catalog Version " << version;

    while ( !in.atEnd() ) {
        if ( version >= 2 ) {
            in >> id;
        }
        if ( id > maxid ) {
            maxid = id;
        }
        in >> ra;
        in >> de;
        in >> mag;
        StarPoint star( id, ( qreal )( ra ), ( qreal )( de ), ( qreal )( mag ) );
        // Create entry in stars database
        m_stars << star;
        // Create key,value pair in idHash table to map from star id to
        // index in star database vector
        m_idHash[id] = starIndex;
        // Increment Index for use in hash
        ++starIndex;
        //mDebug() << "id" << id << "RA:" << ra << "DE:" << de << "MAG:" << mag;
    }
示例#29
0
文件: save.c 项目: OPSF/uClinux
/*
 * Process REGISTER request and save it's contacts
 */
static inline int save_real(struct sip_msg* _m, udomain_t* _t, char* _s, int doreply)
{
	contact_t* c;
	int st;
	str aor, ua;

	rerrno = R_FINE;

	if (parse_message(_m) < 0) {
		goto error;
	}

	if (check_contacts(_m, &st) > 0) {
		goto error;
	}
	
	get_act_time();
	c = get_first_contact(_m);

	if (extract_aor(&get_to(_m)->uri, &aor) < 0) {
		LOG(L_ERR, "save(): Error while extracting Address Of Record\n");
		goto error;
	}

	ua.len = 0;
	if (parse_headers(_m, HDR_USERAGENT, 0) != -1 && _m->user_agent &&
	    _m->user_agent->body.len > 0) {
		ua.len = _m->user_agent->body.len;
		ua.s = _m->user_agent->body.s;
	}
	if (ua.len == 0) {
		ua.len = UA_DUMMY_LEN;
		ua.s = UA_DUMMY_STR;
	}

	if (c == 0) {
		if (st) {
			if (star(_t, &aor) < 0) goto error;
		} else {
			if (no_contacts(_t, &aor) < 0) goto error;
		}
	} else {
		if (contacts(_m, c, _t, &aor, &ua) < 0) goto error;
	}

	if (doreply && (send_reply(_m) < 0)) return -1;
	else return 1;
	
 error:
	if (doreply) send_reply(_m);
	return 0;
}
示例#30
0
//static int getBlockMasks ( PUZZLE *puzzle, int row, int column, int *masks )
static int getBlockMasks ( PUZZLE *puzzle, int row, int column, short **pmasks )

{
   int	status = 0;

#if	defined(DEBUG)
   //fprintf ( logFile, "getBlockMasks ( %p, %d, %d, %p ) {\n", puzzle, row,
								//column, masks );
   fprintf ( logFile, "getBlockMasks ( %p, %d, %d, %p ) {\n", puzzle, row,
								column, pmasks );
   fflush ( logFile );
#endif

   /* Make sure the 3x3 block is not already full. */
   if ( puzzle->blockMasks [row][column] ) {

	int	rowMax = ( row + 1 ) * 3;
	int	columnMax = ( column + 1 ) * 3;
	int	k = 0;
	//int	mask = 0;
	short	mask = 0;
	int	i;

	status = 1;

	/* Make masks for the 3x3 block. */
	for ( i = rowMax - 3; i < rowMax; ++i ) {

		int	j;

		for ( j = columnMax - 3; j < columnMax; ++j ) {

			//masks [k] = puzzle->masks [i][j];
			STAR(pmasks [k]) = puzzle->masks [i][j];
			IFT(pmasks [k], puzzle->pmasks [i][j]);
			//mask |= masks [k];
			mask |= star(pmasks [k]);

			++k;
		}
	}

	if ( mask != puzzle->blockMasks [row][column] ) status = -1;
   }

#if	defined(DEBUG)
   fprintf ( logFile, "} = %d /* getBlockMasks () */\n", status );
   fflush ( logFile );
#endif

   return ( status );
}