首页 > 代码库 > 一些数学函数
一些数学函数
fmod
#include <stdio.h>#include<math.h>int main(int argc, char *argv[]){ float a,b,c; while (scanf("%f %f",&a,&b)) { c=fmod(a,b); printf("%f\n",c); } return 0;}
#include <stdio.h>
#include<math.h>
int main(int argc, char *argv[])
{
float a,b,c;
while (scanf("%f %f",&a,&b))
{
c=fmod(a,b);
printf("%f\n",c);
}
return 0;
}
floor 向下取整
#include <stdio.h>#include<math.h>int main(int argc, char *argv[]){ float a,b,c; while (scanf("%f",&a)) { c=floor(a); printf("%f\n",c); } return 0;}
#include <stdio.h>
#include<math.h>
int main(int argc, char *argv[])
{
float a,b,c;
while (scanf("%f",&a))
{
c=floor(a);
printf("%f\n",c);
}
return 0;
}
ceil 向上取整
#include <stdio.h>#include<math.h>int main(int argc, char *argv[]){ float a,b,c; while (scanf("%f",&a)) { c=ceil(a); printf("%f\n",c); } return 0;}
#include <stdio.h>
#include<math.h>
int main(int argc, char *argv[])
{
float a,b,c;
while (scanf("%f",&a))
{
c=ceil(a);
printf("%f\n",c);
}
return 0;
}
sin正弦函数
#include <stdio.h>#include<math.h>#define PI 3.1415926int main(int argc, char *argv[]){ float a,c; while (scanf("%f",&a)) { c=sin(a/180*PI); printf("%f\n",c); } return 0;}
#include <stdio.h>
#include<math.h>
#define PI 3.1415926
int main(int argc, char *argv[])
{
float a,c;
while (scanf("%f",&a))
{
c=sin(a/180*PI);
printf("%f\n",c);
}
return 0;
}
四舍五入
#include <stdio.h>#include<math.h>int main(int argc, char *argv[]){ float a,b,c; while (scanf("%f",&a)) { c=floor(a+0.5); printf("%f\n",c); } return 0;}
#include <stdio.h>
#include<math.h>
int main(int argc, char *argv[])
{
float a,b,c;
while (scanf("%f",&a))
{
c=floor(a+0.5);
printf("%f\n",c);
}
return 0;
}