From what I understand if N≠0, you will never get the output R since N div 5 will always be supperior to 0 Is there something I'm missing ?
答案 0 :(得分:1)
N := N div 5
最终会将N减少到0;这是整数除法。例如,R
从28开始时的N
和N
值:
r n
3 5
30 1
301 0
使用铅笔和纸张完成算法;你明白了吗?
答案 1 :(得分:0)
it's like while N is different from 0 we affect the value R*10+ (N modulo 5) to R when we get out of the loop (N equals 0) we output R