zoukankan      html  css  js  c++  java
  • 【leetcode】682. 棒球比赛

    int calPoints(char ** ops, int opsSize){
        int arr[1000]={0}, i, pst=0, temp, sum=0;
        for(i=0; i<opsSize; i++){
            if(isdigit(ops[i][0]) || ops[i][0] == '-')
                sscanf(ops[i],"%d",&temp);
            else if(ops[i][0] == 'C'){
                pst--;
                sum -= arr[pst];
                continue;
            }          
            else if(ops[i][0] == 'D')
                temp=arr[pst-1]*2;
            else
                temp=arr[pst-1]+arr[pst-2];
            arr[pst++]=temp;
            sum += temp;
        }
        return sum;
    }
  • 相关阅读:
    Codeforces.468C.Hack it!(构造)
    BZOJ.3227.[SDOI2008]红黑树tree(树形DP 思路)
    146
    145
    144
    143
    142
    141
    140
    139
  • 原文地址:https://www.cnblogs.com/ganxiang/p/14067125.html
Copyright © 2011-2022 走看看