如下代码,请帮忙解答,谢谢。
在main()函数中调用时
为什么用scanf的时候,输入double类型的值时得出的值是:
1,2
x is -92559604281615349000000000000000000000000000000000000000000000.000000,y is -92559604377396321000000000000000000000000000000000000000000000.000000
x value is -92559604281615349000000000000000000000000000000000000000000000.000000,y value is -92559604377396321000000000000000000000000000000000000000000000.000000
min is -92559604377396321000000000000000000000000000000000000000000000.000000,max is -92559604281615349000000000000000000000000000000000000000000000.000000
直接给a,b赋值是正确的。
x value is 1.000000,y value is 2.000000
min is 1.000000,max is 2.000000
#include
#include
void change(double* x, double* y);
int main(void)
{
double a,b;
scanf("%f,%f",&a,&b);
printf("x is %f,y is %f\n",a,b);
change(&a, &b);
a = 1.0;
b = 2.0;
change(&a, &b);
system("pause");
}
void change(double* x, double* y)
{
double min,max;
min = *x;
max = *y;
if(*x > *y)
{
min = *y;
max = *x;
}
printf("x value is %f,y value is %f\nmin is %f,max is %f\n",*x,*y,min,max);
}