Пример #1
0
double unif(){
	s3^=s0<<16;
	s3&=0x7FFFFFFF;
	s0^=s0>>15;
	s0^=s1<<17;
	s1^=s1>>15;
	s1^=s2<<17;
	s2^=s2>>15;
	s2^=s3<<17;
	s3^=s3>>15;
	switch(3L&s3){
		case 1:R unir(s1);
		case 2:R unir(s2);}
	R unir(s0);}
Пример #2
0
void main()
{
  int ndatos, c[20];
  char n, opcion;

  int a[10] = { 2,3,5,7,-8,9,-2,-1,6,0 };
  int b[10] = { 2,3,8,-9,11,12,13,14,15,0 };
  ndatos = 0;
  clrscr();
  do
  {
    menu();
    scanf("%c", &opcion);
    switch(opcion)
    {
      case '1':
      unir(a, b, c, &ndatos);
      clrscr();
      printf("\n UNION");
      imprimir(c, &ndatos);
      getch();
      break;

      case '2':
      intersecar(a, b, c, &ndatos);
      clrscr();
      printf("\n INTERSECCION");
      imprimir(c, &ndatos);
      getch();
      break;

      case 's':
      n = 's';
      break;
    }

  }while(n != 's');

}
Пример #3
0
bool GeometryShadersWindow::CreateScene()
{
    std::string filename;
#if defined(USE_DRAW_DIRECT)
    filename = mEnvironment.GetPath("RandomSquares.hlsl");
#else
    filename = mEnvironment.GetPath("RandomSquaresIndirect.hlsl");
#endif
    std::shared_ptr<VisualProgram> program =
        mProgramFactory.CreateFromFiles(filename, filename, filename);
    if (!program)
    {
        return false;
    }

    // Create particles used by direct and indirect drawing.
    struct Vertex
    {
        Vector3<float> position;
        Vector3<float> color;
        float size;
    };

    // Use a Mersenne twister engine for random numbers.
    std::mt19937 mte;
    std::uniform_real_distribution<float> symr(-1.0f, 1.0f);
    std::uniform_real_distribution<float> unir(0.0f, 1.0f);
    std::uniform_real_distribution<float> posr(0.01f, 0.1f);

    int const numParticles = 128;
    std::vector<Vertex> particles(numParticles);
    for (auto& particle : particles)
    {
        particle.position = { symr(mte), symr(mte), symr(mte) };
        particle.color = { unir(mte), unir(mte), unir(mte) };
        particle.size = posr(mte);
    }

    // Create the constant buffer used by direct and indirect drawing.
    mMatrices = std::make_shared<ConstantBuffer>(
        2 * sizeof(Matrix4x4<float>), true);
    program->GetGShader()->Set("Matrices", mMatrices);

#if defined(USE_DRAW_DIRECT)
    // Create a mesh for direct drawing.
    VertexFormat vformat;
    vformat.Bind(VA_POSITION, DF_R32G32B32_FLOAT, 0);
    vformat.Bind(VA_COLOR, DF_R32G32B32_FLOAT, 0);
    vformat.Bind(VA_TEXCOORD, DF_R32_FLOAT, 0);
    std::shared_ptr<VertexBuffer> vbuffer(new VertexBuffer(vformat,
        numParticles));
    Memcpy(vbuffer->GetData(), &particles[0], numParticles*sizeof(Vertex));
#else
    // Create a mesh for indirect drawing.
    std::shared_ptr<VertexBuffer> vbuffer(new VertexBuffer(numParticles));
    mParticles = std::make_shared<StructuredBuffer>(numParticles,
        sizeof(Vertex));
    Memcpy(mParticles->GetData(), &particles[0], numParticles*sizeof(Vertex));
    gshader->Set("particles", mParticles);
#endif

    std::shared_ptr<IndexBuffer> ibuffer(new IndexBuffer(IP_POLYPOINT,
        numParticles));

    std::shared_ptr<VisualEffect> effect =
        std::make_shared<VisualEffect>(program);

    mMesh = std::make_shared<Visual>(vbuffer, ibuffer, effect);
    return true;
}
Пример #4
0
void retira_b (pagina **raiz, int x, int *s)
{
	int posicion, i, k;
	pagina *p, *q, *r, *t;
	LIFO1 pila;
	void init1_pila (struct LIFO1 *p);
	int pila1_vacia (struct LIFO1 *p);
	void ins1_pila (struct LIFO1 *p,pagina *s,int i);
	void retira1_pila (struct LIFO1 *p,pagina **s,int *i);
	*s = 1;
	init1_pila (&pila);
	esta (*raiz, x, &posicion, &pila);
	if (posicion == -1)
		*s = 0;  /* La llave no existe en el arbol */
	else {
		retira1_pila (&pila, &p, &i);
		if (!hoja (p)) {
			t = p;
			k = i;
			ins1_pila (&pila, p, i+1);
			p = p->apunt [i+1];
			while ( p != NULL) {
				ins1_pila (&pila, p, 0);
				p = p->apunt [0];
			}
			retira1_pila (&pila, &p, &i);
			t->info [k] = p->info [0];
			x = p->info [0];
			posicion = 0;
		}
		if (p->cont > N)
			retirar (p, posicion);
		else {
			if (!pila1_vacia (&pila)) {
				retira1_pila (&pila, &q, &i);
				if (i < q->cont) {
					r = q->apunt [i+1];
					if (r->cont > N) {
						retirar (p, posicion);
						cambio (p, q, r, i, x);
					}
					else {
						if (i != 0) {
						   r = q->apunt [i-1];
						   if (r->cont > N) {
								retirar (p, posicion);
								cambio(p,q,r,i-1,x);
						   }
						   else unir (raiz,q,r,p,
							i-1,pila,x,posicion);
						}
						else unir (raiz,q,r,p,i,pila,
							x,posicion);
					}
				}
				else {
					r = q->apunt [i-1];
					if (r->cont > N) {
						retirar (p, posicion);
						cambio (p,q,r,i-1,x);
					}
					else unir (raiz,q,r,p,i-1,pila,
							x, posicion);
				}
			}
			else {
				retirar (p, posicion);
				if (p->cont == 0) {
					free (*raiz);
					*raiz = NULL;
				}
			}
		}
	}
}