Ò¶Ò¹»¹ ·¢±íÓÚ 2021-3-8 09:23:47

Ϊʲôһֱ±¨´í£¬ÄÄλ´óÉñÖ¸µãÒ»ÏÂ

#include <stdio.h>
void main()
{
        float t,s;
        scanf("%f",&t);
        s=1.0/2*9.8*t*t;
        printf("ÏÂÂä¾àÀëΪ=%f\n",s);

}
Ϊʲôһֱ±¨´í£¬ÄÄλ´óÉñÖ¸µãÒ»ÏÂ

Ò¶Ò¹»¹ ·¢±íÓÚ 2021-3-8 09:24:42

H:\ϵͳĬÈÏ\×ÀÃæ\ѧϰ\CÓïÑÔ\³ÌÐò\ÔÝ´æ\1\1.c(6) : warning C4244: '=' : conversion from 'double ' to 'float ', possible loss of data
ÕâÊDZ¨´íÐÅÏ¢£¬¸Õѧ¿´²»¶®{:10_266:}

orange234561 ·¢±íÓÚ 2021-3-8 10:27:26

Õâ¸öÖ»ÊÇÊý¾ÝÒç³ö£¬¿ÉÒÔ°Ñfloat¸ÄΪdouble£¬%f¸ÄΪ%lf¡£

°Í°Í³ ·¢±íÓÚ 2021-3-8 10:32:43

Ö»ÊÇwarning£¬¿ÉÒÔÔËÐÐ
´íÎóÊÇerror
ÏëÒª¸ü¾«È·¿ÉÒÔÓÃdoubleÀ´½ÓÊÕ½á¹û

crisfo ·¢±íÓÚ 2021-3-8 11:06:36

µ¥¾«¶È float
Ë«¾«¶È double

ÄãÓÃdoubleÊÔÊÔ
Ò³: [1]
²é¿´ÍêÕû°æ±¾: Ϊʲôһֱ±¨´í£¬ÄÄλ´óÉñÖ¸µãÒ»ÏÂ