C语言 求圆面积

[复制链接]
查看11 | 回复2 | 2009-3-5 21:06:46 | 显示全部楼层 |阅读模式
#include
#define PI 3.14159;
Void main( void )
{
double r,s;
printf("input the radius r:");
scanf("%f",&r);
s=PI*r*r;
printf("\nThe acreage is %.2f\n\n",s);
}
输入1后算出面积相当大,怎么回事啊

回复

使用道具 举报

千问 | 2009-3-5 21:06:46 | 显示全部楼层
它在精度转换的时候出了问题,是你scanf("%f",&r); 这句话有问题,你定义了double 就要scanf("%lf",&r); 你定义了float那么就scanf("%f",&r); #include #define PI 3.14159void main( void ) { double r,s; printf("input the radius r:"); scanf("%lf",&r); s=PI*r*r; printf("The acreage is %.2f\n\n",s); }...
回复

使用道具 举报

千问 | 2009-3-5 21:06:46 | 显示全部楼层
用float类型试试吧...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行