13464 - Compare strings or characters   

Description

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:

  1. Just compare the two strings
  2. Compare the first n characters of two strings
  3. Compare the character and the string, considering the character as 1-lengthed string
  4. Similar with the above, only different in the order of the parameters
  5. Compare the character and the n-th character of the string
  6. Similar with the above, only different in the order of the parameters
  7. Just compare the two characters

The first 4 ones are about comparing string, whereas the last 3 ones are just about characters.

 

Input

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|\}\).

Output

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.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13464.cpp

Partial Judge Header

13464.h

Tags




Discuss