早教吧 育儿知识 作业答案 考试题库 百科 知识分享

程序出错:Thevariable'y'isbeingusedwithoutbeinginitialized.子程序doublexuanzhi2(doublexx,doublex)//getyh{doubley;{if(xx>=0&&xx=0.005&&xx=0.015&&xx=0.025&&xx=0.04&&xx=0.075&&xx=0.15&&xx=0.25&&xx=0.4

题目详情
程序出错:The variable 'y' is being used without being initialized.
子程序 double xuanzhi2(double xx,double x)// get yh { double y; {if(xx>=0 && xx=0.005 && xx=0.015 && xx=0.025 && xx=0.04 && xx=0.075 && xx=0.15 && xx=0.25 && xx=0.4 && xx=0.6 && xx=0.75 && xx
▼优质解答
答案和解析
你这个程序,我排列了一下,你可以看到,并不是所有的情况,y都会获得一个值,所以不在处理范围内你也需要为y给定一个值,这样就需要对y定义初始值,比如0.0 double xuanzhi2(double xx,double x)//getyh { double y=0.0; if(xx>=0) { if(xx