依木兰
2018-11-24 21:15
#include<math.h>
double area(double a,double b)
{double s=a*b;
return s;}
#include<stdio.h>
main(){
double a, b ,s;
printf("how much is your long");
scanf("%f",&a);
printf("how much is your wide");
scanf("%f",&b);
s=area(a,b);
printf("%f",s);
}
double 类型使用%f格式会导致输入值错误,换成%lf就可以了。
#include<stdio.h>
#include<math.h>
double area(double a,double b){
double s=a*b;
return s;
}
int main(){
double a, b ,s;
printf("how much is your long");
scanf("%lf",&a);
printf("how much is your wide");
scanf("%lf",&b);
s=area(a,b);
printf("%lf",s);
return 0;
}
C语言入门
926021 学习 · 20793 问题
相似问题