首页 > 其他分享 >2011. 执行操作后的变量值

2011. 执行操作后的变量值

时间:2022-12-23 17:57:07浏览次数:51  
标签:case operations -- res 变量值 break 执行 2011

[2011. 执行操作后的变量值] (https://leetcode.cn/problems/final-value-of-variable-after-performing-operations/description/)

class Solution {
    public int finalValueAfterOperations(String[] operations) {
        int res = 0;
        for (String operation : operations) {
            switch (operation) {
                case "--X" :
                case "X--" :
                    res --; break;
                case "X++" :
                case "++X" :
                    res ++; break;
                default: break;
            }
        }
        return res;
    }
}

标签:case,operations,--,res,变量值,break,执行,2011
From: https://www.cnblogs.com/eiffelzero/p/17001239.html

相关文章