#include main( ) { double d=3.2; int x,y x=1.2; y=(x+3.8)/5.0;printf("%d\n",d*y);}

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 11:42:17
#include main( ) { double d=3.2; int x,y x=1.2; y=(x+3.8)/5.0;printf(
xQJA}Ք@I`b JWXbd$ZAk}fݲ'h~͹srIf?݌9fl"dhPEls6n۵.m=H"[ۼƬ]:ckݞct1+UxS)ƨgϠYjs"CUq6>k#d)?p3j·PQ^=Qq(mA%V`|MԯʫI!%zH)Pt;4Val@@dJA)VV ]ِhUPB&҄CcW}*

#include main( ) { double d=3.2; int x,y x=1.2; y=(x+3.8)/5.0;printf("%d\n",d*y);}
#include main( ) { double d=3.2; int x,y x=1.2; y=(x+3.8)/5.0;printf("%d\n",d*y);}

#include main( ) { double d=3.2; int x,y x=1.2; y=(x+3.8)/5.0;printf("%d\n",d*y);}
结果是0
实际上x=1.2的结果是x=1,那么y也等于0.所以最后的输出结果也是0
在实际编程中,需要注意数据转换的截断以及数据精度问题,比如double d的运算结果是29,但是在计算机中,可能是28.99999999.那么转换成int时,就变成28了,而不是我们希望得到的29

实在看不懂#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;int cases;int main() {double cl = clock();scanf(%d, C++计算阶乘n#include #include #include #include using namespace std;int main(){int sum = 1,d;int n;cin >> n;for(int i=1;i 类的声明和定义 #include #include class bb;void main(){int d;bb dd;d = dd.c;cout #include stdio.h main() { int a,b,sum;#include stdio.hmain(){int a,b,sum;printf(Enter two numbers: );scanf(%d%d,&a,&b);for(;a #include #include void main() {float a,b,c,d; float x0,x1,x2,x3,x4,x5,x6; scanf(%f #include #include int main() { int x,y,sqrt; scanf (%d,&x); y=sqrt(x); if (x> #include #include main() { char p[20]={'a','b','c','d'},q[]=abc,r[]=abcde; 回文串组判断#include #include #include int main(){int i,j,k,T;scanf(%d ,&T);char str[T],yn[T];for (k=0;k # include void main() { int y=10; while(y--); printf(y=%d,y); } #include void main() { int y=10; do{ y--; } while(--y); printf(%d ,--y); } 编程分段函数#include void main(){int x,y;scanf(%d,&x);if(x #include main() { float a,n,i,j,s; scanf(%d,&a); for(n=1.0;n #include main() {char ch; ch='A'+'5'-'3'; printf(%d,%c ,ch,ch); # include void main( ) { int x = 4 ; do { printf( %d ,x-- ) ; } while( x ) ; } main() { #include char *p=ABC; printf(%d,strlen(p)+*p); getch(); }为什么等于68? #include main() { int c=5,k; printf(%d,k=(++c)+(++c)+(++c)); } #include #include void main() { float a,b,c,d; scanf(%d,%d,%d,&a,&b,&c); d=b*b-4 #include main() {int a,b,c,t1,t2; scanf(%d%d%d,&a,&d,&c); t1=a