B. command line arguments

Source: Internet
Author: User
Time limit per test

2 seconds

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make
Sure you 've read the statement attentively and use it as a formal document.

In the pindows operating system a strings are the lexemes of the command line-the first of them is understood as the name of the program to run and the following lexemes are its arguments. for example, as we execute the command "run.exe
One, two. ", we give four lexemes to the pindows command line:" run.exe "," one ,",
"Two", ".". More formally,
If we run a command that can be represented as stringS(That has no quotes), then the command line lexemes are maximal by limit sion substrings
Of stringSThat contain no spaces.

To send a string with spaces or an empty string as a command line lexeme, we can use double quotes. the block of characters that shocould be considered as one lexeme goes inside the quotes. embedded quotes are prohibited-that is, for each occurrence of character
"We shocould be able to say clearly that the quotes are opening or closing. For example, as we run the command" "run.exe
O "ne," Two. ", we give six lexemes to the pindows command line:" run.exe O ",""
(An empty string), "ne,", "two ",
".", "" (A single space ).

It is guaranteed that each lexeme of the command line is either surrounded by spaces on both sides or touches the corresponding command border. one of its consequences is: The opening brackets are either the first character of the string or there is a space
To the left of them.

You have a string that consists of uppercase and lowercase English letters, digits, characters ".,?! "" And spaces. it is guaranteed that this
String is a correct OS pindows command line string. Print all lexemes of this command line string. Consider the character "to be used only
In order to denote a single block of characters into one command line lexeme. In particle, the consequence is that the given string has got an even number of such characters.

Input

The single line contains a non-empty stringS. StringSConsists
Of at most 105 characters.
Each character is either an uppercase or a lowercase English letter, or a digit, or one of ".,?! "" Signs, or a space.

It is guaranteed that the given string is some correct command line string of the OS pindows. it is guaranteed that the given command line string contains at least one lexeme.

Output

In the first line print the first lexeme, in the second line print the second one and so on. To make the output clearer, print the "<" (less)
Character to the left of your lexemes and the ">" (more) character to the right. Print the lexemes in the order in which they occur in the command.

Please, follow the given output format strictly. For more clarifications on the output format see the test samples.

Sample test (s) Input
"RUn.exe O" "" "   2ne, " two! . " "
Output
<RUn.exe O><><   2ne, ><two!><.>< >
Input
   firstarg   second   ""    
Output
<firstarg><second><>

Solution Description: This is the string segmentation. Here, the gets () instead of the scanf () function must be used to read the entire row. A symmetric problem should also be considered, that is to say, starting with "" must end with ", starting with a space must end with a space, similar to matching with parentheses. A string in a pair of symbols is the result to be output.

#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>using namespace std;char s[100005];int main() {int n,i;gets(s);n = strlen(s);for(i=0; i<n; ++i) {if(s[i] == ' '){continue;}printf("<");if(s[i] == '"') {for(++i; s[i]!='"';i++){printf("%c",s[i]);}} else {for(; i<n && s[i]!=' '; i++){printf("%c",s[i]);}}printf(">\n");}return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.