-->
当前位置:首页 > 题库

PROGRAMMING:Class, map

Luz5年前 (2021-05-10)题库388
Summation map: consider and implement a mymap class, which requires at least the following two methods
1、 * * insert * * method: map a pair of (string, integer) key values. If the key already exists, it will be covered.
2、 * * sum * * method: input a prefix string and output the sum of key values beginning with the prefix
###Input format:
In the first line, enter an n to indicate the number of operations to be performed next
Then n lines indicate the operation:
The insert method is followed by a string and an integer separated by a space
The sum method is followed by a string, separated by spaces
**Description * *: assuming no other invalid input is included
###Output example:
Output the sum of key values beginning with the prefix, if not, output 0
###Input example:
```in
three
insert china 5
insert canada 3
sum c
```
###Output example:
```out
eight
```






answer:If there is no answer, please comment