Пример #1
0
int
sort (char *array, int size)
{
  int low = 0;
  int high = size - 1;
  int i;
  char c;
  for (i = 0; i < size && i < high;) {
    if (islow (array[i])) {
      c = array[low];
      array[low] = array[i];

      // printf("array[%d] = %c\n", low, array[i]);
      array[i] = c;
      low++;
    }
    if (ishigh (array[i])) {
      c = array[high];
      array[high] = array[i];
      array[i] = c;
      high--;
    }

    /* If is medium, then move along always, medium will fall into place by itself */
    if (ismedium (array[i]))
      i++;

    /* Incrementing i when islow (first if) doesn't solve the problem, because we already swapped.
     * If the character islow, we should check that it is in the beginning, before low pointer*/
    if (low > i)
      i++;
  }
}
Пример #2
0
 static inline int_type reduce(const A0& x, A0& xr, A0& xc)
 {
   // x is always positive here
   if (all(isalreadyreduced(x))) // all of x are in [0, pi/4], no reduction
   {
     return pio2_reducing<A0>::noreduction(x, xr, xc);
   }
   else if (all(issmall(x))) // all of x are in [0, 20*pi],  cephes algorithm is sufficient for 1 ulp
   {
     return pio2_reducing<A0>::cephes_reduction(x, xr, xc);
   }
   else if (all(ismedium(x))) // all of x are in [0, 2^7*pi/2],  fdlibm medium way
   {
     return pio2_reducing<A0>::fdlibm_medium_reduction(x, xr, xc);
   }
   else  // all of x are in [0, inf],  standard big way
   {
     // This is never taken
     return pio2_reducing<A0>::fdlibm_big_reduction(x, xr, xc);
   }
 }