【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; }