コード例 #1
0
ファイル: questoes.cpp プロジェクト: senapk/arcade
 matriz<int> ebola(const matriz<int> & mat){
     matriz<int> nova(mat);
     int lin = mat.size();
     int col = mat[0].size();
     for(int x = 0; x < col; ++x){
         for(int y = 0; y < lin; ++y){
             if(mat[y][x] > 0){
                 if(tem_amigo_doente(mat, x, y))
                     nova[y][x] = -nova[y][x];
             }
         }
     }
     return nova;
 }
コード例 #2
0
ファイル: lista-encadeada.c プロジェクト: PotHix/pothix-codes
void insere(int x, celula *p){
	celula *q = nova(x);
	q->prox=p->prox;
	p->prox=q;
}
コード例 #3
0
ファイル: torped.c プロジェクト: ajinkya93/netbsd-src
/*ARGSUSED*/
void
torped(int v __unused)
{
	int		ix, iy;
	double		x, y, dx, dy;
	double		angle;
	int		course, course2;
	int		k;
	double		bigger;
	double		sectsize;
	int		burst;
	int		n;

	if (Ship.cloaked) {
		printf("Federation regulations do not permit attack while "
		       "cloaked.\n");
		return;
	}
	if (check_out(TORPED))
		return;
	if (Ship.torped <= 0) {
		printf("All photon torpedos expended\n");
		return;
	}

	/* get the course */
	course = getintpar("Torpedo course");
	if (course < 0 || course > 360)
		return;
	burst = -1;

	/* need at least three torpedoes for a burst */
	if (Ship.torped < 3) {
		printf("No-burst mode selected\n");
		burst = 0;
	} else {
		/* see if the user wants one */
		if (!testnl()) {
			k = ungetc(getchar(), stdin);
			if (k >= '0' && k <= '9')
				burst = 1;
		}
	}
	if (burst < 0) {
		burst = getynpar("Do you want a burst");
	}
	if (burst) {
		burst = getintpar("burst angle");
		if (burst <= 0)
			return;
		if (burst > 15) {
			printf("Maximum burst angle is 15 degrees\n");
			return;
		}
	}
	sectsize = NSECTS;
	n = -1;
	if (burst) {
		n = 1;
		course -= burst;
	}
	for (; n && n <= 3; n++) {
		/* select a nice random course */
		course2 = course + randcourse(n);
		/* convert to radians */
		angle = course2 * 0.0174532925;
		dx = -cos(angle);
		dy =  sin(angle);
		bigger = fabs(dx);
		x = fabs(dy);
		if (x > bigger)
			bigger = x;
		dx /= bigger;
		dy /= bigger;
		x = Ship.sectx + 0.5;
		y = Ship.secty + 0.5;
		if (Ship.cond != DOCKED)
			Ship.torped -= 1;
		printf("Torpedo track");
		if (n > 0)
			printf(", torpedo number %d", n);
		printf(":\n%6.1f\t%4.1f\n", x, y);
		while (1) {
			ix = x += dx;
			iy = y += dy;
			if (x < 0.0 || x >= sectsize ||
			    y < 0.0 || y >= sectsize) {
				printf("Torpedo missed\n");
				break;
			}
			printf("%6.1f\t%4.1f\n", x, y);
			switch (Sect[ix][iy]) {
			  case EMPTY:
				continue;

			  case HOLE:
				printf("Torpedo disappears into a black "
				       "hole\n");
				break;

			  case KLINGON:
				for (k = 0; k < Etc.nkling; k++) {
					if (Etc.klingon[k].x != ix ||
					    Etc.klingon[k].y != iy)
						continue;
					Etc.klingon[k].power -= 500 + ranf(501);
					if (Etc.klingon[k].power > 0) {
						printf("*** Hit on Klingon at "
						       "%d,%d: extensive "
						       "damages\n",
							ix, iy);
						break;
					}
					killk(ix, iy);
					break;
				}
				break;

			  case STAR:
				nova(ix, iy);
				break;

			  case INHABIT:
				kills(ix, iy, -1);
				break;

			  case BASE:
				killb(Ship.quadx, Ship.quady);
				Game.killb += 1;
				break;

			  default:
				printf("Unknown object %c at %d,%d destroyed\n",
					Sect[ix][iy], ix, iy);
				Sect[ix][iy] = EMPTY;
				break;
			}
			break;
		}
		if (damaged(TORPED) || Quad[Ship.quadx][Ship.quady].stars < 0)
			break;
		course += burst;
	}
	Move.free = 0;
}
コード例 #4
0
ファイル: nova.c プロジェクト: AjayRamanathan/gimp
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpDrawable      *drawable;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  run_mode = param[0].data.d_int32;

  *nreturn_vals = 1;
  *return_vals  = values;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  /*  Get the specified drawable  */
  drawable = gimp_drawable_get (param[2].data.d_drawable);

  switch (run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &pvals);

      /*  First acquire information with a dialog  */
      if (! nova_dialog (drawable))
        {
          gimp_drawable_detach (drawable);
          return;
        }
      break;

    case GIMP_RUN_NONINTERACTIVE:
      /*  Make sure all the arguments are there!  */
      if (nparams != 9)
        status = GIMP_PDB_CALLING_ERROR;

      if (status == GIMP_PDB_SUCCESS)
        {
          pvals.xcenter   = param[3].data.d_int32;
          pvals.ycenter   = param[4].data.d_int32;
          pvals.color     = param[5].data.d_color;
          pvals.radius    = param[6].data.d_int32;
          pvals.nspoke    = param[7].data.d_int32;
          pvals.randomhue = param[8].data.d_int32;
        }

      if ((status == GIMP_PDB_SUCCESS) &&
          pvals.radius <= 0)
        status = GIMP_PDB_CALLING_ERROR;
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      /*  Possibly retrieve data  */
      gimp_get_data (PLUG_IN_PROC, &pvals);
      break;

    default:
      break;
    }

  if (status == GIMP_PDB_SUCCESS)
    {
      /*  Make sure that the drawable is gray or RGB color  */
      if (gimp_drawable_is_rgb (drawable->drawable_id) ||
          gimp_drawable_is_gray (drawable->drawable_id))
        {
          gimp_progress_init (_("Rendering supernova"));
          gimp_tile_cache_ntiles (2 *
                                  (drawable->width / gimp_tile_width () + 1));

          nova (drawable, NULL);

          if (run_mode != GIMP_RUN_NONINTERACTIVE)
            gimp_displays_flush ();

          /*  Store data  */
          if (run_mode == GIMP_RUN_INTERACTIVE)
            gimp_set_data (PLUG_IN_PROC, &pvals, sizeof (NovaValues));
        }
      else
        {
          /* gimp_message ("nova: cannot operate on indexed color images"); */
          status = GIMP_PDB_EXECUTION_ERROR;
        }
    }

  values[0].data.d_status = status;

  gimp_drawable_detach (drawable);
}