scanf("%f",&r); ---> scanf("%lf",&r);这儿是原因:Because C will promote floats to doubles for functions that take variable arguments. Pointers aren't promoted to anything, so you should be using %lf or %g to read in doubles....
在 C 语言中,可以使用 %Lf 格式说明符来使用 scanf 函数为 long double 类型的变量赋值,示例如下:include <stdio.h>int main() { long double num;printf("请输入一个 long double 类型的数: ");scanf("%Lf", &num);printf("您输入的数是: %Lf\n", num);return 0;} ...
int N;double c;printf("input the A: ");scanf("%lf",&A);printf("input the N: ");scanf("%d",&N);c=pow(A,N);printf("A^N = %g\n",c);} 这样就没问题了 亲测!
【注意】后面的i,n,k应该是int类型的。include<stdio.h> int main(){ double a[15]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},b;//a和b是double类型 int i,n,k;//其他的是int类型 printf("输入一个数\n");scanf("%lf",&b);//这里是%lf for(i=0,n=15,k=0;k<=3...
double c_temp, f_temp; printf(” Enter the temperature in Celsius: “); scanf (” %lf”, &c_temp); // getting the Celsius temperature f_temp = ( c_temp * 9 / 5 ) + 32; // conversion formula printf (” The temperature in Fahrenheit is: %lf”, f_temp); ...
double in value 在价值上翻一番 double on〔upon〕 迂回,突然袭击 五、用法:1、double用作形容词的基本意思是“双的”,其所修饰的名词一般为单数。2、double常用来表示倍数,后面可接名词、数词、代词,在double与被修饰的名词之间有时还可用定冠词the或物主代词。3、double的基本意思是“对折起来”...
long double: %Lf unsigned char: %hc
include <stdio.h> int main(void){ double max,min,n;int i;scanf("%lf",&max);min=max;for (i=1;i<5;i++){ scanf("%lf",&n);max=max<n?n:max;min=min>n?n:min;} printf("max=%lf\nmin=%lf\n",max,min);return 0;} ...
Format specifier for double in printf() in C When we use theprintf()function for the floating-point data we can use%ffor both float anddouble, and%Lfforlong double, and we can use%lfalso fordouble. In theprintf(), there is no difference but when we usescanf()function for the floatin...
你的C语言程序我帮你改完了,你看看吧(改动的地方见注释)include <stdio.h>int main (){//这里主函数有返回值 double a,b,c; printf("长度:"); scanf("%lf",&a);//如果a是double类型的格式输入要改成%lf b=0.0328084*a; c=0.3937008*a; printf("%.2lfcm %.2lfft %.2lfin",...