#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double mod(double, double);
int main(void)
{
double x, y;
printf("Please input a number \n");
scanf("%lf%lf", &x, &y);
int a1 = x, a2 = y;
printf("Intput %lf, %lf\n",x, y);
printf("Intput %d, %d\n",a1, a2);
printf("INT: %d\n",a1%a2);
printf("INT: %d\n",(int)x%(int)y);
printf("DOU: %f\n",mod(x,y));
printf("DOU: %f\n",fmod(x,y));
system("pause");
return 0;
}
double mod(double a, double b){
double sum = (int)a % (int)b;
return sum;
}
答案是 沒有 !!!!!!!!!!!!!
%只能用在整數型態
要取浮點數的餘數, 請還是記得fmod吧, 他是在#include<math.h> 底下
沒有留言:
張貼留言