请教个double型数的输入问题
时间:2010-08-03
来源:互联网
#include<stdio.h>
#include<string.h>
#include<ctype.h>
double min( double *x, double *y )
{
if(*x>*y)
return *y;
else
return *x;
}
int main(void)
{
double i,j;
printf("please input 2 double num:");
scanf("%f,%f",&i,&j);
printf("\nbetween %.2f and %.2f the min is %.2f\n",i,j,min(&i,&j));
return 0;
}
用gdb调试如下:
(gdb) n
15 scanf("%f,%f",&i,&j);
(gdb) s
please input 2 double num:6,5
16 printf("\nbetween %.2f and %.2f the min is %.2f\n",i,j,min(&i,&j));
(gdb) p i
$1 = 1.5568185538959763e-307
(gdb) p j
$2 = 3.4210311148389101e-307
(gdb)
为什么打印i,j的时候显示的不是6,和5
#include<string.h>
#include<ctype.h>
double min( double *x, double *y )
{
if(*x>*y)
return *y;
else
return *x;
}
int main(void)
{
double i,j;
printf("please input 2 double num:");
scanf("%f,%f",&i,&j);
printf("\nbetween %.2f and %.2f the min is %.2f\n",i,j,min(&i,&j));
return 0;
}
用gdb调试如下:
(gdb) n
15 scanf("%f,%f",&i,&j);
(gdb) s
please input 2 double num:6,5
16 printf("\nbetween %.2f and %.2f the min is %.2f\n",i,j,min(&i,&j));
(gdb) p i
$1 = 1.5568185538959763e-307
(gdb) p j
$2 = 3.4210311148389101e-307
(gdb)
为什么打印i,j的时候显示的不是6,和5
作者: tracyjk1 发布时间: 2010-08-03
double用%lf,你改改试试看刻不

作者: daybreakcx 发布时间: 2010-08-03
回复 tracyjk1
偶的没有问题,可以正常打印。
偶的没有问题,可以正常打印。

作者: donglongchao 发布时间: 2010-08-03
多写楼上的,可以了
作者: tracyjk1 发布时间: 2010-08-03
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28