首页 > 代码库 > 向下向上去整函数

向下向上去整函数

  #include <stdio.h>
  #include <math.h>

  int main ()
  {
   printf ("floor of 2.3 is %d\n", (int )floor (2.3) );
   printf ("floor of 2.6 is %d\n", (int)floor (2.6) );
   printf ("floor of -2.3 is %d\n", (int)floor (-2.3) );
   printf ("floor of -2.6 is %d\n", (int )floor (-2.6) );
   printf ("floor of 2.3 is %d\n", (int )ceil (2.3) );
   printf ("floor of 2.6 is %d\n", (int )ceil (2.6) );
   printf ("floor of -2.3 is %d\n", (int )ceil (-2.3) );
   printf ("floor of -2.6 is %d\n", (int)ceil (-2.6) );
   printf("%d",(int )-2.3);
  return 0;
 }


向下向上去整函数