王老师:19139051760(微信同号)  13333709510
联大   青书学堂   文才   和学   现代兴业   安徽教育在线   超星   弘成   广东开放大学   国家开放大学   上海开放大学   含弘慕课 

教育服务

成人高校
成考录取分数线
我要提升学历
提升学历的理由:
升职加薪、积分落户、考研、公务员考试、子女入学、出国留学


成人高考报名入口

当前位置: 首页 > 学起plus弘成系统 > 石家庄铁道大学> 人工智能
 

输入试题:
本题添加时间:2023/4/3 12:59:00
圆梦客服:王老师  19139051760(微信同号)  19139051760(微信同号)
补齐下述Bresenham算法。
if(delatRow < 0) stepRow = -1;else stepRow = 1;

if(delatCol < 0) stepCol = -1;else stepCol = 1;

delatRow = abs(delatRow *2);

delatCol = abs(delatCol *2);

currentStep = 0;

pathRow [currentStep] = nextRow;

pathCol [currentStep] = nextCol;

currentStep ++ ;

。。。

答案是:正确答案为: if (deltaCol > deltaRow) {
fraction = (deltaRow * 2 – deltaCol)/2;

while (nextCol != endCol) {

if (fraction >= 0) {

nextRow = nextRow + stepRow;

fraction = fraction - deltaCol;

}

nextCol = nextCol + stepCol;

fraction = fraction + deltaRow;

pathRow[currentStep] = nextRow;

pathCol[currentStep] = nextCol;

currentStep++;

}

}

else {

fraction = (deltaCol * 2 – deltaRow)/2;

while (nextRow != endRow) {

if (fraction >= 0) {

nextCol = nextCol + stepCol;

fraction = fraction - deltaRow;

}

nextRow = nextRow + stepRow;

fraction = fraction + deltaCol;

pathRow[currentStep] = nextRow;

pathCol[currentStep] = nextCol;

currentStep++;

}

}

出自 人工智能  学起plus弘成系统

石家庄铁道大学

更多试题>>>>
1、请写出分隔规则实现的代码
2、游戏领域会切割成不连续的砖块(正方形,或正六边形),玩家位置会固定在某个砖块上,不能同时跨越不同的砖格。 × √
3、机器人学是研究在任何条件下都能够完成人类部分的行动或功能的机器 × √
4、计算每一点与终点间的横轴和纵轴,比较二者的长度,往较长轴方向前进,若两轴等长,则沿对角线前进. × √
5、与或图中本原问题对应的节点称为终止节点 × √


提升学历-成人高考报名入口 提升学历-成人高考院校名单