我怎么能在纸上运行这段代码?

时间:2016-11-03 06:36:25

标签: c++

这段代码对我来说很复杂。

    $sql5 = "SELECT id, value FROM pc_taxes WHERE id = :taxId AND client_id = :clientID LIMIT 1";
            $stmt5 = getaccessdata::getInstance()->prepare($sql5);
            $stmt5->bindValue(':clientID', $client_id, PDO::PARAM_INT);
            $stmt5->bindValue(':taxId', $taxID, PDO::PARAM_INT);

            try {
                $stmt5->execute();
                $req5 = $stmt5->fetchAll(PDO::FETCH_ASSOC);
                $countTaxVal = 0;
                foreach ($req5 as $r5) {
                    $countTaxVal++;
                }
            } catch (Exception $e) {

            }

if($countTaxVal>0){
$rowExist=true;
}

我如何用C ++跟踪这段代码,我不知道哪个算子先行动。

2 个答案:

答案 0 :(得分:2)

参见例如

除法和乘法首先从左到右完成:

n = ((n/100) * 100) + ((n%100) / 10) +  ((n%10) * 10)
    ^-------------^   ^------------^    ^-----------^

然后从左到右添加:

n = ( (  ((n/100) * 100) + ((n%100) / 10) ) +  ((n%10) * 10) )
    | ^-----------------------------------^                  |
    +--------------------------------------------------------+

最后是作业。

答案 1 :(得分:1)

结果是总和3部分

temp1 = n     / 100;    # it is integer division (decimal part is throwing out)
temp1 = temp1 * 100;

temp2 = n     % 100;    # remainder after division by 100, i. e. last 2 digits
temp2 = temp2 /  10;

temp3 = n     %  10;    # remainder after division by  10, i. e. last digit
temp3 = temp3 *  10;

n     = temp1 + temp2 + temp3;