Compare to C, it's much more easy for us to compare two strings by means of using relational operators directly. Nevertheless, there are still something inconvinient.For instance, we could compare a single character (which is regarded as 1-length string) with a string in Python, yet not in C++ since the concering operators is not overloaded.
On the other hand, there is a brand new operator called three way comparison coming with C++20, which return \(1\) if the left hand side is greater than the right hand side, \(0\) if the two sides are equal, \(-1\) otherwise.
So in this partial-judged problem, your task is to implement the function cmp()
to stimulate the behavior of that operator on strings and characters and extend the feature. cmp() should accept the following 7 sort of parameters:
The first 4 ones are about comparing string, whereas the last 3 ones are just about characters.
Since this problem is judged partially, you needn't be concerned about the format of input.
In case your're interested, there at most 100 lines in a test file. Each line contains two string, \(s, t\) and a integer \(n < \min\{|s|, |t|\}\).
Since this problem is judged partially, you needn't be concerned about the format of output.
In case your're interested, for each line input, print the result of comparing \(s\) and \(t\), the first \(n\) characters of \(s\) and \(t\), \(s\) and the last character of \(t\), the first character of \(s\) and \(t\), the \(n^{th}\) character of \(s\) and the last character of \(t\), the first character of \(s\) and the \(n^{th}\) character of \(t\), the last character of \(s\) and the first character of \(t\) in a line separated by spaces and ended with a new line character.