小编Yas*_*_1D的帖子

试图了解Shunting Yard算法

我正在尝试使用Shunting-yard算法,所以我开始研究它.在这样做的同时,我发现了一些我不太了解的有趣文档:

    // Current token is a number, push 
    // it to stack for numbers. 
    else if(isdigit(tokens[i])){ 
        int val = 0; 

        // There may be more than one 
        // digits in number. 
        while(i < tokens.length() && 
                    isdigit(tokens[i])) 
        { 
            val = (val*10) + (tokens[i]-'0'); 
            i++; 
        } 

        values.push(val); 
    } 
Run Code Online (Sandbox Code Playgroud)

我不明白为什么在里面while,变量val乘以10(val=(val*10)).有人可以帮助我理解为什么算法必须这样做?

c++ postfix-notation shunting-yard

1
推荐指数
1
解决办法
72
查看次数

标签 统计

c++ ×1

postfix-notation ×1

shunting-yard ×1