Beispiel #1
0
int
main(int argc, char const *argv[])
{
	char bitmap[MAX_SIZE];
	memset(bitmap, 0, sizeof(bitmap));
	char *ptr = bitmap;
	int number_in = 0;
	int number_search = 0;
	int i = 0;

	printf("Please input the numbers continuously(less than and not equal %d) "
		"that will be saved in the bit map and enter the number -1 to finish!\n", 
		MAX_SIZE * sizeof(char) * 8);
	while(EOF != (scanf("%d", &number_in)))
	{
		if(-1 == number_in)
			break;

		ptr = bitmap;

		if(MAX_SIZE <= QUOTIENT(number_in))
			return 0;

		for (i = 0; i < QUOTIENT(number_in); ++i)
		{
			ptr++;
		}
		*ptr |= (0x01 << REMAINDER(number_in));
	}

	printf("Please input the numbers continuously(less than and not equal %d) "
		"that will be searched whether in the bit map or not and enter the number -1 to finish!\n", 
		MAX_SIZE * sizeof(char) * 8);
	while(EOF != (scanf("%d", &number_search)))
	{
		if(-1 == number_search)
			break;

		char location = (char)0;
		ptr = bitmap;

		if(MAX_SIZE < QUOTIENT(number_search))
			return 0;
		for (i = 0; i <= QUOTIENT(number_search); ++i)
		{		
			ptr++;
		}
		location = (*ptr) & (location | (0x01 << REMAINDER(number_search)));

		if(0 == location)
			printf("the number %d is not exist!\n", number_search);
		else
			printf("the number %d is exist!\n", number_search);
	}
	
	return 0;
}
Beispiel #2
0
int main(int argc, const char* argv[])
{

#ifdef TEST
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	//!输入
	int num_a = 0, num_b = 0;
	scanf("%d%d", &num_a, &num_b);

	//!计算
	int remainder = REMAINDER(num_a, num_b);

	//!输出
	printf("%d\n", remainder);

	return 0;
}
Beispiel #3
0
/* Size of a simple object. */
rt_public size_t eif_objsiz(size_t nb_ref, size_t nb_char, size_t nb_int16, size_t nb_int32, size_t nb_r32, size_t nb_ptr, size_t nb_int64, size_t nb_r64)
{
	size_t to_add = eif_r64off(nb_ref,nb_char, nb_int16,nb_int32,nb_r32,nb_ptr, nb_int64) + R64ACS(nb_r64);
	return to_add + REMAINDER(to_add);
}
Beispiel #4
0
/**
 * Used to compute texel locations for linear sampling for four texcoords.
 * \param wrapMode  PIPE_TEX_WRAP_x
 * \param s  the texcoords
 * \param size  the texture image size
 * \param icoord0  returns first texture indexes
 * \param icoord1  returns second texture indexes (usually icoord0 + 1)
 * \param w  returns blend factor/weight between texture indexes
 * \param icoord  returns the computed integer texture coords
 */
static INLINE void
linear_texcoord_4(unsigned wrapMode, const float s[4], unsigned size,
                  int icoord0[4], int icoord1[4], float w[4])
{
   uint ch;

   switch (wrapMode) {
   case PIPE_TEX_WRAP_REPEAT:
      for (ch = 0; ch < 4; ch++) {
         float u = s[ch] * size - 0.5F;
         icoord0[ch] = REMAINDER(util_ifloor(u), size);
         icoord1[ch] = REMAINDER(icoord0[ch] + 1, size);
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_CLAMP:
      for (ch = 0; ch < 4; ch++) {
         float u = CLAMP(s[ch], 0.0F, 1.0F);
         u = u * size - 0.5f;
         icoord0[ch] = util_ifloor(u);
         icoord1[ch] = icoord0[ch] + 1;
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
      for (ch = 0; ch < 4; ch++) {
         float u = CLAMP(s[ch], 0.0F, 1.0F);
         u = u * size - 0.5f;
         icoord0[ch] = util_ifloor(u);
         icoord1[ch] = icoord0[ch] + 1;
         if (icoord0[ch] < 0)
            icoord0[ch] = 0;
         if (icoord1[ch] >= (int) size)
            icoord1[ch] = size - 1;
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
      {
         const float min = -1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            float u = CLAMP(s[ch], min, max);
            u = u * size - 0.5f;
            icoord0[ch] = util_ifloor(u);
            icoord1[ch] = icoord0[ch] + 1;
            w[ch] = FRAC(u);
         }
      }
      break;;
   case PIPE_TEX_WRAP_MIRROR_REPEAT:
      for (ch = 0; ch < 4; ch++) {
         const int flr = util_ifloor(s[ch]);
         float u;
         if (flr & 1)
            u = 1.0F - (s[ch] - (float) flr);
         else
            u = s[ch] - (float) flr;
         u = u * size - 0.5F;
         icoord0[ch] = util_ifloor(u);
         icoord1[ch] = icoord0[ch] + 1;
         if (icoord0[ch] < 0)
            icoord0[ch] = 0;
         if (icoord1[ch] >= (int) size)
            icoord1[ch] = size - 1;
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_MIRROR_CLAMP:
      for (ch = 0; ch < 4; ch++) {
         float u = fabsf(s[ch]);
         if (u >= 1.0F)
            u = (float) size;
         else
            u *= size;
         u -= 0.5F;
         icoord0[ch] = util_ifloor(u);
         icoord1[ch] = icoord0[ch] + 1;
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
      for (ch = 0; ch < 4; ch++) {
         float u = fabsf(s[ch]);
         if (u >= 1.0F)
            u = (float) size;
         else
            u *= size;
         u -= 0.5F;
         icoord0[ch] = util_ifloor(u);
         icoord1[ch] = icoord0[ch] + 1;
         if (icoord0[ch] < 0)
            icoord0[ch] = 0;
         if (icoord1[ch] >= (int) size)
            icoord1[ch] = size - 1;
         w[ch] = FRAC(u);
      }
      break;;
   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
      {
         const float min = -1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            float u = fabsf(s[ch]);
            if (u <= min)
               u = min * size;
            else if (u >= max)
               u = max * size;
            else
               u *= size;
            u -= 0.5F;
            icoord0[ch] = util_ifloor(u);
            icoord1[ch] = icoord0[ch] + 1;
            w[ch] = FRAC(u);
         }
      }
      break;;
   default:
      assert(0);
   }
}
Beispiel #5
0
/**
 * Apply texture coord wrapping mode and return integer texture indexes
 * for a vector of four texcoords (S or T or P).
 * \param wrapMode  PIPE_TEX_WRAP_x
 * \param s  the incoming texcoords
 * \param size  the texture image size
 * \param icoord  returns the integer texcoords
 * \return  integer texture index
 */
static INLINE void
nearest_texcoord_4(unsigned wrapMode, const float s[4], unsigned size,
                   int icoord[4])
{
   uint ch;
   switch (wrapMode) {
   case PIPE_TEX_WRAP_REPEAT:
      /* s limited to [0,1) */
      /* i limited to [0,size-1] */
      for (ch = 0; ch < 4; ch++) {
         int i = util_ifloor(s[ch] * size);
         icoord[ch] = REMAINDER(i, size);
      }
      return;
   case PIPE_TEX_WRAP_CLAMP:
      /* s limited to [0,1] */
      /* i limited to [0,size-1] */
      for (ch = 0; ch < 4; ch++) {
         if (s[ch] <= 0.0F)
            icoord[ch] = 0;
         else if (s[ch] >= 1.0F)
            icoord[ch] = size - 1;
         else
            icoord[ch] = util_ifloor(s[ch] * size);
      }
      return;
   case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
      {
         /* s limited to [min,max] */
         /* i limited to [0, size-1] */
         const float min = 1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            if (s[ch] < min)
               icoord[ch] = 0;
            else if (s[ch] > max)
               icoord[ch] = size - 1;
            else
               icoord[ch] = util_ifloor(s[ch] * size);
         }
      }
      return;
   case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
      {
         /* s limited to [min,max] */
         /* i limited to [-1, size] */
         const float min = -1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            if (s[ch] <= min)
               icoord[ch] = -1;
            else if (s[ch] >= max)
               icoord[ch] = size;
            else
               icoord[ch] = util_ifloor(s[ch] * size);
         }
      }
      return;
   case PIPE_TEX_WRAP_MIRROR_REPEAT:
      {
         const float min = 1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            const int flr = util_ifloor(s[ch]);
            float u;
            if (flr & 1)
               u = 1.0F - (s[ch] - (float) flr);
            else
               u = s[ch] - (float) flr;
            if (u < min)
               icoord[ch] = 0;
            else if (u > max)
               icoord[ch] = size - 1;
            else
               icoord[ch] = util_ifloor(u * size);
         }
      }
      return;
   case PIPE_TEX_WRAP_MIRROR_CLAMP:
      for (ch = 0; ch < 4; ch++) {
         /* s limited to [0,1] */
         /* i limited to [0,size-1] */
         const float u = fabsf(s[ch]);
         if (u <= 0.0F)
            icoord[ch] = 0;
         else if (u >= 1.0F)
            icoord[ch] = size - 1;
         else
            icoord[ch] = util_ifloor(u * size);
      }
      return;
   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
      {
         /* s limited to [min,max] */
         /* i limited to [0, size-1] */
         const float min = 1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            const float u = fabsf(s[ch]);
            if (u < min)
               icoord[ch] = 0;
            else if (u > max)
               icoord[ch] = size - 1;
            else
               icoord[ch] = util_ifloor(u * size);
         }
      }
      return;
   case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
      {
         /* s limited to [min,max] */
         /* i limited to [0, size-1] */
         const float min = -1.0F / (2.0F * size);
         const float max = 1.0F - min;
         for (ch = 0; ch < 4; ch++) {
            const float u = fabsf(s[ch]);
            if (u < min)
               icoord[ch] = -1;
            else if (u > max)
               icoord[ch] = size;
            else
               icoord[ch] = util_ifloor(u * size);
         }
      }
      return;
   default:
      assert(0);
   }
}
Beispiel #6
0
double Timeline::ActiveTimeToSimpleTime(double tau, int* iteration)
{
	// m_simpleDur has accounted for autoReverse
	double m_AD = 99999;
	double m_simpleDur = get_Duration();
	double m_dur = get_Duration();

	double AD = m_AD;//m_dur;// ? AD=Active Duration?
	double speed = get_SpeedRatio();//m_speed->m_value->m_value->m_value;

	double acc = get_AccelerationRatio();//m_accelerate->m_value->m_value->m_value;
	double dec = get_DecelerationRatio();//m_decelerate->m_value->m_value->m_value;

	if (acc+dec > 1)	// Ignore both attributes
	{
		acc = 0;
		dec = 0;
	}

	double taf;

	if (speed > 0) // i.e. if the local speed is forwards 
		taf = tau * speed;
	else //  i.e. if the local speed is backwards 
		taf = AD - tau * fabs(speed);

	//Let dur be the value of the simple duration as defined by the Timing and Synchronization model.
	// This is the actual simple duration, and not simply the dur attribute.
	//This value does not account for the effect of any time manipulations.
	double dur = m_dur;
	ASSERT(dur >= 0);
	//if (dur < 0) dur = INDEFINITE;	// indefinite (Is this correct?)

	// m_simpleDur has accounted for autoReverse
	double dur_ = m_simpleDur;

#if 1	// Have something like this
	double tsu = REMAINDER(taf, dur_);
#else
	double tsu = taf;
#endif

	if (iteration)
	{	// ??
		*iteration = (int)(taf/dur_);
	}

// Account for autoReverse behavior.
	double tsu_;

	if (!get_AutoReverse())
	{
		tsu_ = tsu;
	}
	else
	{
		if (tsu < dur)
			tsu_ = tsu;
		else
			//tsu_ = /*dur - (tsu - dur) =*/ 2*dur - tsu;
			tsu_ = 2*dur - tsu;
	}

// Calculate filtered time (tsf)

// Account for acceleration/deceleration
	double tsf;

	double dacc = acc*dur;
	double ddec = dec*dur;

	double r = 1 / (1 - acc/2 - dec/2);

	if (tsu_ >= 0 && tsu_ < dacc)
	{
		double rt = r * (tsu_ / dacc);

		tsf = tsu_ * rt / 2;
	}
	else if (tsu_ > (dur - ddec))
	{
		double rt = r * (dur - tsu_) / ddec;

		double tdec =  tsu_ - (dur - ddec);
		double pd =  tdec / ddec;

		tsf = r * (dur - dacc / 2 - ddec + tdec * (2 - pd) / 2);
	}
	else
	{
		tsf = r * (tsu_ - dacc / 2);
	}

//	tsf = tsf + m_iteration*dur_;	// ???? TODO remove this

	return tsf;
}