Java程序 如何判断一个点在圆内还是圆外平面坐标系哪一象限 坐标(x,y)给出?
1个回答
展开全部
String xiangxian = "";
if(x<0)
if(y<0) xiangxian = "3";
else if(y>0) xiangxian = "2";
else xiangxian = "x负轴";
else if (x>0)
if(y<0) xiangxian = "4";
else if(y>0) xiangxian = "1";
else xiangxian = "x正轴"
else
if(y<0) xiangxian = "y负轴";
else if(y>0) xiangxian = "y正轴";
else xiangxian = "原点"
//再给你整个三目运算符的:
String xx = "";
xx=(x>0) ? ( (y>0)?"1":( (y<0)? "4" : "X+" ) ) : ( (x<0) ? ( (y>0)?"2":( (y<0)? "3" : "X-" ) ) :( (y>0)?"Y+":( (y<0)? "Y-" : "0" ) ) );
if(x<0)
if(y<0) xiangxian = "3";
else if(y>0) xiangxian = "2";
else xiangxian = "x负轴";
else if (x>0)
if(y<0) xiangxian = "4";
else if(y>0) xiangxian = "1";
else xiangxian = "x正轴"
else
if(y<0) xiangxian = "y负轴";
else if(y>0) xiangxian = "y正轴";
else xiangxian = "原点"
//再给你整个三目运算符的:
String xx = "";
xx=(x>0) ? ( (y>0)?"1":( (y<0)? "4" : "X+" ) ) : ( (x<0) ? ( (y>0)?"2":( (y<0)? "3" : "X-" ) ) :( (y>0)?"Y+":( (y<0)? "Y-" : "0" ) ) );
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询