为什么输入"2,3"以后输出为0(注意:没输入引号)逗号也是英文半角

原问题:为什么输入"2,3"以后输出为0(注意:没输入引号)逗号也是英文半角
分类:编程开发 > 最后更新时间:【2016-12-16 11:25:39】
问题补充:

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

int main()

{

int a;

double b,c;

scanf("%f,%d",&b,&a);

c=pow(b,a);

printf("%f",c);

system("pause");

return 0;

}

最佳答案

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

main()

{

int a, b;

double c; /*b定义为int*/

scanf("%d,%d",&b,&a);/*改成%d*/

c=pow(b,a);

printf("%f",c);

system("pause");

return 0;

}

这样运行,结果为8.000000

最佳答案由网友  aasdasd1  提供
公告: 为响应国家净网行动,部分内容已经删除,感谢网友理解。
11

分享到:

其他回答

其它网友回答:
你的问题很简单,定义什么都不用改

其它网友回答:
只要改你的两个%f为%lf就可以得到正确的结果为

其它网友回答:
%f是输入/输出float的,而double要用%lf

其它网友回答:

    推荐