新南威尔士大学COMP9021 QUIZ3课业解析

  • May 15, 2020

新南威尔士大学COMP9021 QUIZ3课业解析题意:按照移动规则进行移动,规则是0-7的数字为从北开始的顺时针的八个方向,每移动到一个位置,将该位置的开关反转(on变成off,off变成on),然后进行下一次的移动,初始条件是原点的开关为on,其他所有位置为off。 解析:先将输入的十进制整数转换为八进制,如果输入是由0开始的,则保留0。随后按照转换的八进制数字,从左向右的移动,每次移动,对移动到的位置的开关状态进行改变,最后保留为上下左右四个最远方向的状态为on的点的矩形。如测试案例,3654转换为八进制为7106,向下为正北方向,白点为on,黑点为off,每次移动过后都以新的点为起始点左上角白点为起始点,7106,就是右下,左下,向下,向右的移动轨迹,经过的点变为on状态,取出这个所有on状态的最小的矩形输出即可涉及知识点:python列表更多可加微信讨论微信号:Ssss_970521pdfQUIZ 3

COMP9021 PRINCIPLES OF PROGRAMMINGReading the number written in base 8 from right to left, keeping the leading 0’s, if any:0: Move North1: Move North-East2: Move East3: Move South-East4: Move South5: Move South West6: Move West7: Move North-WestWe start from a position that is the unique position where the switch is on.Moving to a position switches on to off, off to on there.$ python3 quiz_3.pyEnter a non-strictly negative integer: 0Keeping leading 0’s, if any, in base 8, 0 reads as 0.⚪ ⚪$python3 quiz_3.pyEnter a non-strictly negative integer: 00Keeping leading 0’s, if any, in base 8, 00 reads as 00.⚪ ⚪ ⚪$python3 quiz_3.pyEnter a non-strictly negative integer: 0256Keeping leading 0’s, if any, in base 8, 0256 reads as 0400.⚪$python3 quiz_3.pyEnter a non-strictly negative integer: 032Keeping leading 0’s, if any, in base 8, 032 reads as 040.$ python3 quiz_3.pyEnter a non-strictly negative integer: 3654Keeping leading 0’s, if any, in base 8, 3654 reads as 7106.⚪⚫⚫⚪⚪⚫⚪⚪Date: Term 3, 2019.2 COMP9021 PRINCIPLES OF PROGRAMMING$ python3 quiz_3.pyEnter a non-strictly negative integer: 100738324Keeping leading 0’s, if any, in base 8, 100738324 reads as 600222424.⚪⚫⚫⚪⚪⚪⚪⚫⚫⚪⚫⚪⚪⚪⚪$ python3 quiz_3.pyEnter a non-strictly negative integer: 73776Keeping leading 0’s, if any, in base 8, 73776 reads as 220060.⚪⚪⚪⚪⚫⚫⚪⚪⚫⚫⚪⚫$ python3 quiz_3.pyEnter a non-strictly negative integer: 7704322Keeping leading 0’s, if any, in base 8, 7704322 reads as 35307402.⚪⚫⚪⚫⚫⚫⚫⚪$ python3 quiz_3.pyEnter a non-strictly negative integer: 206537612Keeping leading 0’s, if any, in base 8, 206537612 reads as 1423701614.⚪⚫⚫⚫⚫⚫⚪⚪⚫⚪⚪⚫⚫⚪⚫⚫⚪⚫⚫⚫$ python3 quiz_3.pyEnter a non-strictly negative integer: 000123456789Keeping leading 0’s, if any, in base 8, 000123456789 reads as 000726746425.⚪⚫⚫⚫⚪⚫⚫⚫⚪⚫⚫⚪⚪⚫⚪⚪⚪⚫⚪⚪⚫⚫⚪⚫

LATEST POSTS
MOST POPULAR

ezAce多年来为广大留学生提供定制写作、留学文书定制、语法润色以及网课代修等服务,超过200位指导老师为您提供24小时不间断地服务。