13485 - String Calculator(class)   

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 lines.

For each a b, output ((a - b)+b)/b

Sample Input  Download

Sample Output  Download

Partial Judge Code

13485.cpp

Partial Judge Header

13485.h

Tags




Discuss