C语言 求圆面积#include "stdio.h"main(){double r,area;printf("input r please(r>0)");scanf("%f\n",&r);area=3.1416*r*r;printf("r=%6.2f\n",r);printf("area=%d\n",area);}这是改完后的书上写的是main(){float r,area;printf("input r please(r>0)

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/18 11:25:36
C语言求圆面积#include"stdio.h"main(){doubler,area;printf("inputrplease(r>0)");scanf("%f\n",&r);area=3.1416

C语言 求圆面积#include "stdio.h"main(){double r,area;printf("input r please(r>0)");scanf("%f\n",&r);area=3.1416*r*r;printf("r=%6.2f\n",r);printf("area=%d\n",area);}这是改完后的书上写的是main(){float r,area;printf("input r please(r>0)
C语言 求圆面积
#include "stdio.h"
main()
{double r,area;
printf("input r please(r>0)");
scanf("%f\n",&r);
area=3.1416*r*r;
printf("r=%6.2f\n",r);
printf("area=%d\n",area);
}
这是改完后的
书上写的是
main()
{float r,area;
printf("input r please(r>0)");
scanf("%f\n",r);
area=3.1416*r*r;
printf("r=%6.2f\n",r);
printf("area=%d\n",area);
}
本来就是一个改错题 但运行出来不对啊

C语言 求圆面积#include "stdio.h"main(){double r,area;printf("input r please(r>0)");scanf("%f\n",&r);area=3.1416*r*r;printf("r=%6.2f\n",r);printf("area=%d\n",area);}这是改完后的书上写的是main(){float r,area;printf("input r please(r>0)
呵呵这回一定好了.上机实验了一下.问题主要在scanf语句.您的语句是scanf("%f\n",&r);因为“”中有换行符\n,所以输入时候要输入逗号才能出结果.现在把\n去掉就行了.
scanf中引号中的符号也是要输入的.比如scanf("%d,%d",&a,&b);和语句scanf("%d %d",&a,&b);语句的不同之处是,第一个输入数值以后要输入逗号隔开,第二语句要用空格隔开数字.
还有的错误就是用%lf表示double.原语句写的是%d ,%f等等
我前几天也是这没有弄明白,后来在聊天群里问的别人.加个聊天群问也不错.
#include "stdio.h"
#include "stdlib.h"
main()
{double r,area;
printf("input r please(r>0)");
scanf("%lf",&r);
area=3.1416*r*r;
printf("r=%6.2lf\n",r);
printf("area=%lf\n",area);
system("pause");
}