[Huawei OD Machine Test 2023 Latest] Shooting Contest (100% solution in C language)

topic description

You are now the scorer of a special-format shooting contest. The game consists of several rounds, and the scores of past rounds may affect the scores of later rounds.
When the game starts, the record is blank. You will get a string list ops
that records operations , where ops[i] is the i-th operation you need to record, and ops follows the following rules:

  • Integer x-indicates the new score x obtained in this round
  • "+" – Indicates that the new score obtained in this round is the sum of the previous two scores.
  • "D" - Indicates that the new score obtained in this round is double the previous score.
  • "C" - Indicates that no points were scored for the round, and the previous score is invalid and removed from the record.

Please return the sum of all scores in the record.

enter description

input as an array of strings

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130233360