Educational Codeforces Round 2 A. Extract Numbers 模拟题

A. Extract Numbers

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/600/problem/A

Description

You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, the strings=";;" contains three empty words separated by ';'.

You should find all words in the given string that are nonnegative INTEGER numbers without leading zeroes and build by them new string a. String a should contain all words that are numbers separating them by ',' (the order of numbers should remain the same as in the string s). By all other words you should build string b in the same way (the order of numbers should remain the same as in the strings).

Here strings "101", "0" are INTEGER numbers, but "01" and "1.0" are not.

For example, for the string aba,123;1a;0 the string a would be equal to "123,0" and string b would be equal to "aba,1a".

Input

The only line of input contains the string s (1 ≤ |s| ≤ 105). The string contains only symbols '.' (ASCII 46), ',' (ASCII 44), ';' (ASCII 59), digits, lowercase and uppercase latin letters.

Output

Print the string a to the first line and string b to the second line. Each string should be surrounded by quotes (ASCII 34).

If there are no words that are numbers print dash (ASCII 45) on the first line. If all words are numbers print dash on the second line.

Sample Input

aba,123;1a;0

Sample Output

"123,0"
"aba,1a"

HINT

题意

给你一行字符串,然后让你分别出,哪些是没有含有前导0的整数

哪些是字符串

题解:

单纯的模拟题,注意,小数也是字符串,其他就没什么了

代码:

#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std; string s;
vector<string>A[];
int main()
{
cin>>s;
int flag = ;
string S;
for(int i=;i<s.size();i++)
{
if(s[i]==';'||s[i]==',')
{
if(flag==)
{
if(S.size()!=&&S[]=='')
flag = ;
if(S.size()==)
flag = ;
}
A[flag].push_back(S);
flag = ;
S="";
}
if(s[i]<='Z'&&s[i]>='A')
{
S+=s[i];
flag = ;
}
if(s[i]<='z'&&s[i]>='a')
{
S+=s[i];
flag = ;
}
if(s[i]<=''&&s[i]>='')
{
S+=s[i];
}
if(s[i]=='.')
{
S+=s[i];
flag = ;
}
}
if(flag==)
{
if(S.size()!=&&S[]=='')
flag = ;
if(S.size()==)
flag = ;
}
A[flag].push_back(S);
if(A[].size()==)
{
printf("-\n");
}
else
{
printf("\"");
for(int i=;i<A[].size();i++)
{
if(i!=A[].size()-)
cout<<A[][i]<<",";
else cout<<A[][i]<<"\""<<endl;
}
}
if(A[].size()==)
{
printf("-\n");
}
else
{
printf("\"");
for(int i=;i<A[].size();i++)
{
if(i!=A[].size()-)
cout<<A[][i]<<",";
else cout<<A[][i]<<"\""<<endl;
}
}
}
上一篇:面向.NET开发人员的Dapr- actors 构建块


下一篇:Codeforces Beta Round #5 B. Center Alignment 模拟题