示例#1
0
文件: npot_tex.c 项目: haimoz/steveo
void makePotTex(const struct jpeg_img *img, struct npot_tex *tex)
{
	/* tid is assigned by other routines */
	/* only care about calculating the Power-Of-Two size and clip size in s-t texture coordiantes */
	tex->real_width = img->width;
	tex->real_height = img->height;
	tex->pot_width = pot(tex->real_width);
	tex->pot_height = pot(tex->real_height);
	tex->clip_width = tex->real_width / (double)tex->pot_width;
	tex->clip_height = tex->real_height / (double)tex->pot_height;
	tex->per_eye_aspect = tex->real_width / (double)tex->real_height;
	/* correct the real aspect ratio for stereo images */
	if (img->is_stereo) {
		tex->is_stereo = 1;
		tex->per_eye_aspect /= 2;
	} else {
		tex->is_stereo = 0;
	}
	/* copy data and pad */
	tex->data = malloc(tex->pot_width * tex->pot_height * 3);
	int rowStride = tex->pot_width * 3;
	int rowLength = tex->real_width * 3;
	unsigned char *imgPtr;
	unsigned char *dataPtr;
	int row;
	for (imgPtr=img->data, dataPtr=tex->data, row=0; row < tex->real_height; imgPtr+=rowLength, row++, dataPtr+=rowStride) {
		memcpy(dataPtr, imgPtr, rowLength);
	}
	return;
}
示例#2
0
int checkIfTriplet(int a, int b, int c){
  if(a < b && b < c){
    if( pot(c) == (pot(a) + pot(b) )){
      return 1;
    }
  }
  return 0;
}
示例#3
0
static bool d3d_upload_bitmap(ALLEGRO_BITMAP *bitmap)
{
   ALLEGRO_BITMAP_D3D *d3d_bmp = (ALLEGRO_BITMAP_D3D *)bitmap;
   int w = bitmap->w;
   int h = bitmap->h;

   if (d3d_bmp->display->device_lost)
      return false;

   if (d3d_bmp->initialized != true) {
      bool non_pow2 = al_have_d3d_non_pow2_texture_support();
      bool non_square = al_have_d3d_non_square_texture_support();

      if (non_pow2 && non_square) {
         // Any shape and size
         d3d_bmp->texture_w = w;
	 d3d_bmp->texture_h = h;
      }
      else if (non_pow2) {
         // Must be sqaure
         int max = _ALLEGRO_MAX(w,  h);
         d3d_bmp->texture_w = max;
         d3d_bmp->texture_h = max;
      }
      else {
         // Must be POW2
         d3d_bmp->texture_w = pot(w);
         d3d_bmp->texture_h = pot(h);
      }

      // Some cards/drivers don't like small textures
      if (d3d_bmp->texture_w < 16) d3d_bmp->texture_w = 16;
      if (d3d_bmp->texture_h < 16) d3d_bmp->texture_h = 16;

      if (d3d_bmp->video_texture == 0)
         if (!d3d_create_textures(d3d_bmp->display, d3d_bmp->texture_w,
               d3d_bmp->texture_h,
               d3d_bmp->bitmap.flags,
               &d3d_bmp->video_texture,
               &d3d_bmp->system_texture,
               bitmap->format)) {
            return false;
         }

      /*
       * Keep track of created bitmaps, in case the display is lost
       * or resized.
       */
      *(ALLEGRO_BITMAP_D3D **)_al_vector_alloc_back(&created_bitmaps) = d3d_bmp;

      d3d_bmp->initialized = true;
   }

   d3d_do_upload(d3d_bmp, 0, 0, w, h, false);

   return true;
}
示例#4
0
文件: pot.c 项目: kubota/CRepo
/* testa funcao pot */
main() {
	
	int i;

	for (int i = 0; i < 10; ++i) {
		printf("%d %d %d\n", i, pot(2,i), pot(-3, i) );
	}	
	return 0;
}
示例#5
0
文件: ranics.c 项目: srs51/SRS-3000
void generate(PARAMS *p,SSDATA *d)
{
	double GPE,KE,f;
	int i,j;

	for (i=0;i<p->N;i++) {
		gen_body(p,&d[i],i);
		for (j=0;j<i;j++)
			if (OVERLAP(d[i].pos,d[i].radius,d[j].pos,d[j].radius)) {
				(void) printf("Particle %i overlaps particle %i\n"
							  "-- regenerating particle %i\n",i,j,i);
				--i;
				break;
				}
		}

	GPE = KE = 0.0;
	for (i=0;i<p->N;i++) {
		GPE += d[i].mass*pot(p,d,i);
		KE += 0.5*d[i].mass*MAG_SQ(d[i].vel);
		}

	(void) printf("Starting KE = %g = %g times GPE\n",KE,KE/GPE);

	assert(KE > 0.0);

	f = -0.5*p->KEf*GPE/KE;

	assert(f >= 0.0);

	for (i=0;i<p->N;i++)
		reset_vel(p,f,&d[i]);

	GPE = KE = 0.0;
	for (i=0;i<p->N;i++) {
		GPE += d[i].mass*pot(p,d,i);
		KE += 0.5*d[i].mass*MAG_SQ(d[i].vel);
		}

	(void) printf("Adjusted KE = %g = %g times GPE (= %g times virial)\n",KE,KE/GPE,-2*KE/GPE);

	{
	double t_dyn,t_step;

	t_dyn = 2*sqrt(CUBE(p->Rd)/(p->N*p->m));
	(void) printf("Dynamical time ~ %g\n",t_dyn);
	t_step = 2*sqrt(CUBE(p->R)/p->m)/33;
	(void) printf("Recommended time step < %g\n",t_step);
	(void) printf("Estimated number of steps needed per t_dyn = %i\n",(int) (t_dyn/t_step + 0.5));
	}
	}
示例#6
0
文件: mod.cpp 项目: D4ryus/studium
/* function to calculate the potency (a^n % q) */
Mod Mod::pot(unsigned int n){
	if(n == 0){
		return Mod(1);
	}else{
		if(n == 1){
			return Mod(get_a());
		}
		if(n % 2 == 0){
			return pot(n/2) * pot(n/2);
		}
		if(n % 2 == 1){
			return pot(n-1) * Mod(get_a());
		}
	}
}
示例#7
0
ComplexType ExternalPotential::operator()(PosType r){
    ComplexType pot(0,0);
    for (int i=0;i<_pset.n;i++){
        pot -= _pset.ptcls[i]->q/( (r-_pset.ptcls[i]->r).norm() );
    }
    return pot;
}
示例#8
0
int main()
{
	int N, C, testes, i, j;
	int INV, A;
	scanf("%d", &testes);
	fat[0] = 0;
	fat[1] = 1;
	for(i=2; i<2000001; i++)
	{
		fat[i] = ((long long)fat[i-1]*i)%MOD;
		if(i < 1000001)
			inv[i] = pot(fat[i], MOD-2);
	}
	for(i=0;i<testes;i++)
	{
		scanf("%d %d", &N, &C);
		INV = 1;
		if (C+N > MOD) 
		{
			printf("0\n");
		} 
		else
		{
			INV = ((long long)inv[N-1]*inv[C])%MOD;
			A = ((long long)fat[N+C-1]*INV)%MOD;
			printf("%d\n", A);
		}
	}
	return 0;
}
示例#9
0
文件: main.cpp 项目: DavidKendall/iot
static void appTaskMonitor(void *pdata) {

	MMA7455 acc(P0_27, P0_28);
	AnalogIn pot(p15);
  LM75B lm75B(P0_27, P0_28, LM75B::ADDRESS_1);


	d->setCursor(2,2);
	if (!acc.setMode(MMA7455::ModeMeasurement)) {
    d->printf("Unable to set mode for MMA7455!\n");
  }
	else {
	  if (!acc.calibrate()) {
      d->printf("Failed to calibrate MMA7455!\n");
    }
		else {
	    d->printf("MMA7455 initialised\n");
		}
  }
  lm75B.open();
	
  while ( true ) {
		acc.read(nodeData.ax, nodeData.ay, nodeData.az);
		nodeData.pt = (int32_t)((1.0F - pot.read()) * 100);
    nodeData.js = 0;
		nodeData.tm = lm75B.temp();
    (void)OSSemPost(dataSem); 
    OSTimeDly(200);    
  }
}
示例#10
0
int main(int argc, char* argv[])
{
    CPointerPot pot(32000);
    int i, j, k;
    TPotItem itm;
    clock_t t1, t2;


    for (i = 0;  i < 164000;  i++) {
        itm = rand();
        pot.Add(itm);
    }

    t1= clock();
    pot.Sort(my_cmp);
    t2= clock();
    printf("done in %ld\n", (long)(t2 - t1));

    for (i=0;  i < 31900;  i+= 500) {
        for (j = i;  j < i+10;  j++) {
            k = (int) pot.get(j);
            printf("%d\t", k);
        }
        printf("\n");
    }
}
bool CSymbolEngineChipAmounts::EvaluateSymbol(const char *name, double *result, bool log /* = false */) {
  FAST_EXIT_ON_OPENPPL_SYMBOLS(name);
	if (memcmp(name, "pot", 3)==0) {
		// CHIP AMOUNTS 1(2)
		if (memcmp(name, "pot", 3)==0 && strlen(name)==3)	{
			*result = pot();
		}	else if (memcmp(name, "potcommon", 9)==0 && strlen(name)==9) {
			*result = potcommon();
		}	else if (memcmp(name, "potplayer", 9)==0 && strlen(name)==9) {
			*result = potplayer();
		}	else {
			// Invalid symbol
			return false;
		}
		// Valid symbol
		return true;
	}	else if (memcmp(name, "balance", 7)==0)	{
		if (memcmp(name, "balance", 7)==0 && strlen(name)==7)	{
			*result = p_table_state->User()->_balance; 
		}	else if (memcmp(name, "balance", 7)==0 && strlen(name)==8) {
			*result = p_table_state->_players[name[7]-'0']._balance;
		}	else if (memcmp(name, "balanceatstartofsession", 23)==0 && strlen(name)==23) {
			*result = balanceatstartofsession();
		} else if (memcmp(name, "balance_rank", 12)==0 && strlen(name)==13) {
      *result = SortedBalance(name[12]-'0');
    }	else {
			// Invalid symbol
			return false;
		}
		// Valid symbol
		return true;
	}
	if (memcmp(name, "maxbalance", 10)==0 && strlen(name)==10) {
		*result = maxbalance();
	}	else if (memcmp(name, "stack", 5)==0 && strlen(name)==6) {
		*result = stack(name[5]-'0');
	}	else if (memcmp(name, "currentbet", 10)==0 && strlen(name)==10)	{
		*result = currentbet(p_symbol_engine_userchair->userchair());
	}	else if (memcmp(name, "currentbet", 10)==0 && strlen(name)==11)	{
		*result = currentbet(name[10]-'0');
	}	else if (memcmp(name, "call", 4)==0 && strlen(name)==4)	{
		*result = call();
	}	else if (memcmp(name, "nbetstocall", 11)==0 && strlen(name)==11) {
		*result = nbetstocall();
	}	else if (memcmp(name, "nbetstorais", 11)==0 && strlen(name)==11) {
		*result = nbetstorais();
	}	else if (memcmp(name, "ncurrentbets", 12)==0 && strlen(name)==12)	{
		*result = ncurrentbets();
	}	else if (memcmp(name, "ncallbets", 9)==0 && strlen(name)==9) {
		*result = ncallbets();
	}	else if (memcmp(name, "nraisbets", 9)==0 && strlen(name)==9) {
		*result = nraisbets();
	}	else {
		// Symbol of a different symbol-engine
		return false;
	}
	// Valid symbol
	return true;
}
示例#12
0
void inventory::form_from_map(game *g, point origin, int range)
{
 items.clear();
 for (int x = origin.x - range; x <= origin.x + range; x++) {
  for (int y = origin.y - range; y <= origin.y + range; y++) {
   if (g->m.has_flag(sealed, x, y))
     continue;
   for (int i = 0; i < g->m.i_at(x, y).size(); i++)
    if (!g->m.i_at(x, y)[i].made_of(LIQUID))
     add_item(g->m.i_at(x, y)[i]);
// Kludges for now!
   ter_id terrain_id = g->m.ter(x, y);
   furn_id furniture_id = g->m.furn(x, y);
   if ((g->m.field_at(x, y).findField(fd_fire)) || (terrain_id == t_lava)) {
    item fire(g->itypes["fire"], 0);
    fire.charges = 1;
    add_item(fire);
   }
   if (terrain_id == t_water_sh || terrain_id == t_water_dp){
    item water(g->itypes["water"], 0);
    water.charges = 50;
    add_item(water);
   }

   int vpart = -1;
   vehicle *veh = g->m.veh_at(x, y, vpart);

   if (veh) {
     const int kpart = veh->part_with_feature(vpart, vpf_kitchen);
     const int weldpart = veh->part_with_feature(vpart, vpf_weldrig);

     if (kpart >= 0) {
       item hotplate(g->itypes["hotplate"], 0);
       hotplate.charges = veh->fuel_left("battery", true);
       add_item(hotplate);

       item water(g->itypes["water_clean"], 0);
       water.charges = veh->fuel_left("water");
       add_item(water);

       item pot(g->itypes["pot"], 0);
       add_item(pot);
       item pan(g->itypes["pan"], 0);
       add_item(pan);
       }
     if (weldpart >= 0) {
       item welder(g->itypes["welder"], 0);
       welder.charges = veh->fuel_left("battery", true);
       add_item(welder);

       item soldering_iron(g->itypes["soldering_iron"], 0);
       soldering_iron.charges = veh->fuel_left("battery", true);
       add_item(soldering_iron);
       }
     }
   }

  }
 }
示例#13
0
main(){
   int ncases, cases, a, b;
   for( scanf("%d", &ncases), cases = 1; cases <= ncases ; cases++){
      scanf("%d %d", &a, &b);
      printf("%lld\n", pot(((long long)a)%MOD, (long long)b));
   }
   return 0;    
}
示例#14
0
int pot(int m, int n)
{
	if (n == 1) {
		return m;
	}

	return m * pot(m, n - 1);
}
 int testPotentialFunction()
 {
     StandardValuePotentialFunction pot(5.0);
     CHECK_EQ(pot.ratePosition(0.0, 0.0), 5.0);
     CHECK_EQ(pot.ratePosition(GPSPosition(5.0, 6.0)), 5.0);
     CHECK_EQ(pot.ratePosition(5.0, 6.0), pot.ratePosition(GPSPosition(5.0, 6.0)));
     
     return EXIT_SUCCESS;
 }
示例#16
0
 inline friend bool cmp(const line &p, const line &q) {
     pot v = p.v;
     v = pot(v.y, -v.x);
     if(v.y == 0) return p.a.y < q.a.y || (p.a.y == q.a.y && p.a.x < q.a.x);
     else {
         db px = (p.a.x*v.y-p.a.y*v.x)/(db)v.y, qx = (q.a.x*v.y-q.a.y*v.x)/(db)v.y;
         return px < qx && !equal(px, qx);
     }
 }
		pair<int, int> mcmf(int source, int sink){
			ll flow = 0, cost = 0;
			vector<pair<int,int>> p(V, {-1, -1});
			vector<ll> pot(V, 0);
			d.assign(V, -1);

			while(true){

			}
		}
示例#18
0
文件: utiles.c 项目: mrabinovichm/rf2
int arrToInt(char * buf, int largo_buf)
{
	int i, numero;
	numero = 0;
	
	for(i=0; i<largo_buf; i++) 
		numero += ((int)buf[i] - (int)'0') * pot(10, largo_buf -1 -i);
		
	return numero;
}
示例#19
0
static void show_cursor(ALLEGRO_DISPLAY_RASPBERRYPI *d)
{
    if (d->cursor_data == NULL || cursor_added) {
        return;
    }

    int width = d->cursor_width;
    int height = d->cursor_height;

    uint32_t unused;
    cursor_resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, width, height, &unused);

    VC_RECT_T r;
    r.x = 0;
    r.y = 0;
    r.width = width;
    r.height = height;

    int dpitch = pot(sizeof(uint32_t) * width);

    dispman_update = vc_dispmanx_update_start(0);
    vc_dispmanx_resource_write_data(cursor_resource, VC_IMAGE_ARGB8888, dpitch, d->cursor_data, &r);
    vc_dispmanx_update_submit_sync(dispman_update);

    ALLEGRO_MOUSE_STATE state;
    al_get_mouse_state(&state);

    dst_rect.x = state.x+d->cursor_offset_x;
    dst_rect.y = state.y+d->cursor_offset_y;
    dst_rect.width = width;
    dst_rect.height = height;
    src_rect.x = 0;
    src_rect.y = 0;
    src_rect.width = width << 16;
    src_rect.height = height << 16;

    dispman_update = vc_dispmanx_update_start(0);

    cursor_element = vc_dispmanx_element_add(
                         dispman_update,
                         dispman_display,
                         0/*layer*/,
                         &dst_rect,
                         cursor_resource,
                         &src_rect,
                         DISPMANX_PROTECTION_NONE,
                         0 /*alpha*/,
                         0/*clamp*/,
                         0/*transform*/
                     );

    vc_dispmanx_update_submit_sync(dispman_update);

    cursor_added = true;
}
示例#20
0
int main(int argc, char** argv)
{

    int k,n;
    scanf("%d%d", &k, &n);
    printf("%d", pot(k,n));
    double poc=0., kraj=1000., sr, rez;
    int i;
    for(i=0; i<40; i++) {
        sr = (poc+kraj)/2;
        rez = pot(sr, k);
        //printf("%lf\n", sr);
        if( n<rez ) kraj=sr;
        if( n>rez ) poc=sr;
        if( n==rez ) break;
    }
    printf("SR: %lf\n", sr);

    return 0;
}
示例#21
0
文件: forms.cpp 项目: alieed/hermes
Scalar bilinear_form_H(int n, double *wt, Func<Scalar> *u_ext[], Func<Real> *u, 
                     Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)

{
  Scalar result = 0;
  for (int i=0; i < n; i++) {
    double x = e->x[i];
    double y = e->y[i];
    result +=4*PI*x*wfun(x,y)*(u->dx[i]*v->dx[i]+u->dy[i]*v->dy[i])*wt[i]+pot(x, y)*4*PI*x*wfun(x,y)*u->val[i]*v->val[i]* wt[i];
  }
  return result;
}
示例#22
0
int main (int argc, char *argv[]) {
    int ctrl, i, x = 1, b = atoi (argv[1]), k = atoi (argv[2]);
    for (i = 1; i <= k; i++) {
        ctrl = pot (b, i, &x);
        if (ctrl == STATUS_FAIL) {
            printf ("Overflow aritmetico\n");
            return 0;
        }
        printf ("%10d | %10d \n", x, piso_log2 (x));
    }
    return 0;
}
示例#23
0
int main(){
	float angulo, velocidadeInicial, distancia, espessura, altura,
		momento1, momento2, alturaProjetil1, alturaProjetil2;
	unsigned short int colidiu;

	/* obtencao dos dados */
	printf("Angulo de lancamento: ");
	scanf("%f", &angulo); limpa_entrada();
	printf("Velocidade inicial (m/s): ");
	scanf("%f", &velocidadeInicial); limpa_entrada();
	printf("Distancia do objeto (m): ");
	scanf("%f", &distancia); limpa_entrada();
	printf("Espessura do objeto (m): ");
	scanf("%f", &espessura); limpa_entrada();
	printf("Altura do objeto (m): ");
	scanf("%f", &altura); limpa_entrada();

	/* calculo dos instantes em que o projetil passa pelos limites
	   do objeto */
	momento1 = distancia/(velocidadeInicial * cos(angulo * 3.1415/180));
	momento2 = (distancia + espessura)/
			(velocidadeInicial * cos(angulo * 3.1415/180));

	/* calculo da altura do projetil nos dois instantes */
	alturaProjetil1 = velocidadeInicial * sen(angulo * 3.1415/180)
				* momento1 - 9.8 * pot(momento1, 2)/2;
	alturaProjetil2 = velocidadeInicial * sen(angulo * 3.1415/180)
				* momento1 - 9.8 * pot(momento1, 2)/2;

	/* verificacao da colisao */
	colidiu = alturaProjetil1 <= altura && alturaProjetil1 > 0 ||
			alturaProjetil2 <= altura && alturaProjetil2 > 0;

	/* resultado */
	printf("Houve colisao? %d\n", colidiu);

	return 0;
}
示例#24
0
int main(int argc, char *argv[])
{

#   include "setRootCase.H"
#   include "createTime.H"
#   include "createMesh.H"

    potential pot(mesh);

    moleculeCloud molecules(mesh, pot);

#   include "temperatureAndPressureVariables.H"

#   include "readmdEquilibrationDict.H"

    label nAveragingSteps = 0;

    Info << "\nStarting time loop\n" << endl;

    while (runTime.loop())
    {

        nAveragingSteps++;

        Info << "Time = " << runTime.timeName() << endl;

        molecules.evolve();

#       include "meanMomentumEnergyAndNMols.H"

#       include "temperatureAndPressure.H"

#       include "temperatureEquilibration.H"

        runTime.write();

        if (runTime.outputTime())
        {
            nAveragingSteps = 0;
        }

        Info << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
            << "  ClockTime = " << runTime.elapsedClockTime() << " s"
            << nl << endl;
    }

    Info << "End\n" << endl;

    return 0;
}
示例#25
0
文件: perfmon.cpp 项目: Jinxiaohai/QT
void PerfMon::drawGraph(QPainter *painter)
{
    painter->save();


    for(int i = 0;i<m_nChannelCount;i++)
    {
        // check to see if there's a need to draw specified data channel
        if(!m_visibleVec.at(i))
        {
            continue ;
        }

        // customize specified channel's graph color

        painter->setPen(QPen(m_clrVec.at(i)));

        QVector<qreal> dataVec = m_dataVec[i];


        QVector<QPointF> potVec;
        qreal startX = width();
        for(int j = 0;j < dataVec.count();j++)
        {
               qreal yValue = dataVec.at(j);
               qreal y = yValue*((qreal)height()/100);
               QPointF pot(startX,height()-y);

               //
               if(j<(dataVec.count()-1))
               {
                   qreal yNextValue=dataVec.at(j+1);
                   qreal yNext=yNextValue*((qreal)height()/100);
                   QPointF nextPot(startX-m_nIncrement,height()-yNext);
                   potVec.push_back(nextPot);
               }

               //

               startX-=m_nIncrement;

               //
               potVec.push_back(pot);
        }
        painter->drawLines(potVec);
    }

    painter->restore();
}
示例#26
0
static void set_cursor_data(ALLEGRO_DISPLAY_RASPBERRYPI *d, uint32_t *data, int width, int height)
{
    al_free(d->cursor_data);
    int spitch = sizeof(uint32_t) * width;
    int dpitch = pot(spitch);
    d->cursor_data = al_malloc(dpitch * height);
    int y;
    for (y = 0; y < height; y++) {
        uint8_t *p1 = (uint8_t *)d->cursor_data + y * dpitch;
        uint8_t *p2 = (uint8_t *)data + y * spitch;
        memcpy(p1, p2, spitch);
    }
    d->cursor_width = width;
    d->cursor_height = height;
}
示例#27
0
int pot (int b, int p)
{
	if (p == 0)
		return 1;
	/* b^p mod m */
	int tmp;
	b %= m;
	tmp = pot (b, p/2) % m;
	tmp = (tmp * tmp) % m;

	if ( p%2 == 1)
		tmp = (tmp * b) % m;

	return tmp % m;
}
示例#28
0
void inventory::form_from_map(game *g, point origin, int range)
{
 items.clear();
 for (int x = origin.x - range; x <= origin.x + range; x++) {
  for (int y = origin.y - range; y <= origin.y + range; y++) {
   for (int i = 0; i < g->m.i_at(x, y).size(); i++)
    if (!g->m.i_at(x, y)[i].made_of(LIQUID))
     add_item(g->m.i_at(x, y)[i]);
// Kludges for now!
   if (g->m.field_at(x, y).type == fd_fire) {
    item fire(g->itypes["fire"], 0);
    fire.charges = 1;
    add_item(fire);
   }
   ter_id terrain_id = g->m.ter(x, y);
   if (terrain_id == t_toilet || terrain_id == t_water_sh || terrain_id == t_water_dp){
    item water(g->itypes["water"], 0);
    water.charges = 50;
    add_item(water);
   }

   int vpart = -1;
   vehicle *veh = g->m.veh_at(x, y, vpart);

   if (veh) {
     const int kpart = veh->part_with_feature(vpart, vpf_kitchen);

     if (kpart >= 0) {
       item hotplate(g->itypes["hotplate"], 0);
       hotplate.charges = veh->fuel_left(AT_BATT, true);
       add_item(hotplate);

       item water(g->itypes["water_clean"], 0);
       water.charges = veh->fuel_left(AT_WATER);
       add_item(water);

       item pot(g->itypes["pot"], 0);
       add_item(pot);
       item pan(g->itypes["pan"], 0);
       add_item(pan);
     }
   }

  }
 }
}
示例#29
0
int main(){

	int i = 0, j = 0, v = 0, w = 0;
	int m = 0, k = 0, a = 0, r = 0;
	double p = 0, P = 0;

	while(scanf("%d %d %d %lf", &n, &m, &k, &p) != EOF){
		for(i = 0; i < n; i++){
			peso[i] = 0;

			for(j = 0; j < n; j++)
				G[i][j] = 0;
		}

		for(i = 0; i < m; i++){
			scanf("%d %d", &v, &w);
			edge(v - 1, w - 1);
		}

		scanf("%d", &a);

		for(i = 0; i < a; i++){
			scanf("%d", &r);
			peso[r - 1]++;
		}

		scanf("%d %d", &v, &w);

		v--;
		w--;

		dijkstra(v, w);

		P = 0;

		if(dis[w] <= k)
			P = pot(p, dis[w]);

		printf("%.3lf\n", P);
	}

	return 0;
}
示例#30
0
int main()
{
  int m, n, i;

	for (i = 0; i < 5; i++) {
		printf("UTILIZANDO FUNCAO RECURSIVA\n");
		scanf(" %d", &m);
	  scanf(" %d", &n);
		printf("%d", pot(m,n));
	}

	for (i = 0; i < 5; i++) {
		printf("UTILIZANDO FOR\n");
		scanf(" %d", &m);
	  scanf(" %d", &n);
		printf("%d", pot2(m,n));
	}
	
  return 0;
}