其他分享
首页 > 其他分享> > 实现伪代码进制转换

实现伪代码进制转换

作者:互联网

伪代码进制转换

伪代码

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

错误的尝试

起初的想法是按照翻译英语一样,按照每句话的意思翻译伪代码,但遇到一些问题,最后放弃了这种想法。

改正后的代码



标签:Set,转换,进制,代码,Write,answer,quotient,decimalNumber
来源: https://www.cnblogs.com/wujiuchun/p/15510977.html