zoukankan      html  css  js  c++  java
  • 20201220蔡笃俊进制转换的学习

    娄老师给出的伪代码是英文= =,一开始绕晕我了,给大家翻译一一下,以免像我一样= =
    newBase在这伪代码中的意思应该是新的进制数,decimalNumber是你要转换的数,quotient是短除法的商,remainder是余数。这样一来伪代码就很容易看懂了。
    Write "Enter the new base"
    Read newBase
    Write "Enter the number to be converted"
    Read decimalNumber
    Set quotient to 1
    WHILE (quotient is not zero)
    Set quotient to decimalNumber DIV newBase
    Set remainder to decimalNumber REM newBase
    Make the remainder the next digit to the left in the answer
    Set decimalNumber to quotient
    Write "The answer is "
    Write answer

    经过宿舍内的讨论(课代表带飞),我们认为这个伪代码是这样表示的:先输入要转换的进制数,再输入你要读取的数,然后利用短除法,将要转换的数除去进制数,将余数从右到左排列

    代码实现如下:

    测试:
    结果正确,至此,完成。

  • 相关阅读:
    [bzoj1095] [ZJOI2007]Hide 捉迷藏
    [bzoj3730] 震波
    [bzoj3672] [Noi2014]购票
    [bzoj4129] Haruna’s Breakfast
    《CSS3知识点》
    《表单总结》
    <表格>
    《HTML总结》
    <java程序大集合>
    《字符串的概念》
  • 原文地址:https://www.cnblogs.com/acacacaac/p/13929772.html
Copyright © 2011-2022 走看看