大佬求解!,為什么我輸long是1.1,wide是1.1,結果出來一大串不知所云的數字。根本不是結果
#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);
}
2018-11-26
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;
}