13485 - String Calculator(class)
|
Time |
Memory |
Case 1 |
1 sec |
32 MB |
Case 2 |
1 sec |
32 MB |
Case 3 |
1 sec |
32 MB |
Case 4 |
1 sec |
32 MB |
Case 5 |
1 sec |
32 MB |
Case 6 |
1 sec |
32 MB |
Description
In this problem, you need to finish a string calculator.
The calculator has three string operators:
- a + b: Concatenate the string b after the string a.
- a - b: If string b has appeared in string a, delete the first appearance of b in a, otherwise the result is "error".
- a / b: The number of occurrences of string b in string a.
Note: You are suggested to practice the usage of C++ string class (https://www.cplusplus.com/reference/string/string/).
- function std::operator+: Concatenate strings (https://www.cplusplus.com/reference/string/string/operator+/)
- public member function std::string::find: Find content in string (https://www.cplusplus.com/reference/string/string/find/)
- public member function std::string::substr: Generate substring (https://www.cplusplus.com/reference/string/string/substr/)
- etc.
Input
The first line contains an integer N
The following N lines, each line contains two string a b.
testcases:
(6/6) 1 <= N <= 100, 1 <= |a|, |b| <= 100
Output
The output contains N lines.
For each a b, output ((a - b)+b)/b
Partial Judge Code
13485.cpp
Partial Judge Header
13485.h
Tags