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 ",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
",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 ",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
",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 ",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
",c);
}
return 0;
}
sin正弦函数
#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 ",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
",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 ",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
",c);
}
return 0;
}