I need help understanding this flowchart algorithm

时间:2018-04-18 18:07:30

标签: algorithm flowchart

enter image description here

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 ?

2 个答案:

答案 0 :(得分:1)

N := N div 5最终会将N减少到0;这是整数除法。例如,R从28开始时的NN值:

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