Loading Now

questionCorrection

A system of Online Q&A needs user’s questions to be standardized.

A standardized question must satisfy this following rules:

  • Common rules: Question only contains letter (a-zA-Z), number, comma, space, question mark characters. Other character should be replaced by space.
  • Space rules:
    No space in the head of sentence, no space in the end of sentence. No more than 1 space between the words in 1 sentence.
    There must be a letter or number after a space.
  • Comma rules:
    There must be a letter or number before a comma and only 1 space after a comma.
  • Uppercase / lowercase rules:
    The first letter in a sentence must be an uppercase
    All of other letter in a sentence must be lowercase except for the first letter.
  • Question mark rules:
    There is alway has one question mark at the end of sentence.
    There must be 1 letter before a question mark.
    If the question mark appears in the middle of sentence then replace the question mark by a space.

Input/Output:

  • [execution time limit] 0.5 seconds (cpp)
  • [input] string x
    string of input letters which contains atleast one letter (a-zA-Z)
  • [output] string
    String of letters which are standardized according to the rules of system

Post Comment

Contact