Extract Numbers
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 string s=";;" 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 string s).

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 wordsare numbers print dash on the second line.

Examples
input

Copy
aba,123;1a;0
output

Copy
"123,0"
"aba,1a"
input

Copy
1;;01,a0,
output

Copy
"1"
",01,a0,"
input

Copy
1
output

Copy
"1"
-
input

Copy
a
output

Copy
-
"a"
Note

In the second example the string s contains five words: "1", "", "01", "a0", "".

题意:

给你一个字符串,以‘,’或‘;’来分割单词,并让你给单词分类,a类放没有前导0的非负整数单词,b类放除a类以外的单词,如果某个类为空则输出'-',否则用引号""括起答案输出

思路:

现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
接着要统计a类和b类单词个数
如果到了一个单词的结束分割符','或';',则把则个字符标记为分割符,并判断要把当前单词加入a类还是b类,默认当前单词是a类,如果当前单词存在一个非整数位或有前导零则当前单词属于b类
接着看怎么添加单词,如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词,否则先添一个','再添如当前单词
输出时如果某个类为空则输出'-',否则用引号""括起答案输出

 #include<bits/stdc++.h>
using namespace std;
const int amn=1e5+;
char s[amn],a[amn],b[amn],tmp[amn];
struct index{
int st,ed;
}idx[amn];
int main(){
ios::sync_with_stdio();
cin>>s;
int len=strlen(s);
s[len]=';'; ///现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
int st=,ed=,tp=;
int atp=,btp=,f=,it=; ///atp和btp分别是统计a类和b类单词个数
for(int i=;i<=len;i++){
if(s[i]==','||s[i]==';'){ ///到了一个单词的结束
s[i]=;
if(f&&s[it]){
if(++atp==)strcat(a,s+it); ///如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词
else strcat(a,","),strcat(a,s+it); ///否则先添一个','再添如当前单词
}
else{
if(++btp==)strcat(b,s+it);
else strcat(b,","),strcat(b,s+it);
}
it=i+;
f=; ///默认是符合条件的非负整数
}
else if(s[i]<''||s[i]>''||((i==||s[i-]==)&&s[i]==''&&(s[i+]>=''&&s[i+]<='')))f=; ///如果当前单词存在一个非整数位或有前导零则当前单词属于b类
}
int alen=strlen(a),blen=strlen(b);
if(atp){
printf("\"");
for(int i=;i<alen;i++){
printf("%c",a[i]);
}
printf("\"\n");
}
else{ ///如果没单词,则输出-下面同理
printf("-\n");
}
if(btp){
printf("\"");
for(int i=;i<blen;i++){
printf("%c",b[i]);
}
printf("\"\n");
}
else{
printf("-\n");
}
}
/***
给你一个字符串,以‘,’或‘;’来分割单词,并让你给单词分类,a类放没有前导0的非负整数单词,b类放除a类以外的单词,如果某个类为空则输出'-',否则用引号""括起答案输出
现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
接着要统计a类和b类单词个数
如果到了一个单词的结束分割符','或';',则把则个字符标记为分割符,并判断要把当前单词加入a类还是b类,默认当前单词是a类,如果当前单词存在一个非整数位或有前导零则当前单词属于b类
接着看怎么添加单词,如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词,否则先添一个','再添如当前单词
输出时如果某个类为空则输出'-',否则用引号""括起答案输出
***/

最新文章

  1. 在VS里配置及查看IL
  2. C# “配置系统未能初始化” 异常解决
  3. Tween + 缓动函数
  4. Tomcat Context配置(转)
  5. python计算文件的行数和读取某一行内容的实现方法
  6. js获取上传文件内容(未完待续)
  7. SVM推导
  8. python登陆教务管理系统
  9. HTC T328W刷机包 仿三星S5 UI美化 精简 S5落下
  10. iPad开发中UIPopoverController的使用
  11. Jquery那些坑
  12. spring学习笔记一 入门及配置
  13. Linux-01初级学习
  14. vue2入坑随记(一)-- 初始全家桶
  15. 2017-12-04 编写Visual Studio Code插件初尝试
  16. Java线程池ThreadPoolExecutor&amp;&amp;Executors
  17. python爬取微信信息--显示性别/地域/词云(附代码)
  18. HDU4328 Cut the cake(动规:最大子矩形问题/悬线法)
  19. 【gRPC使用问题1】gRPC的proto内import其他proto导致的一次小坑
  20. [jquery] 遮罩弹窗,点击遮罩弹窗自动隐藏

热门文章

  1. Swift Property
  2. HTML笔记02
  3. 创建git密钥
  4. Windows GDI 窗口与 Direct3D 屏幕截图
  5. C++编码规范(转)
  6. spring——AOP原理及源码(五)
  7. Python之接口测试(一)
  8. C#桌面开发的未来WebWindow
  9. TARS基金会:构建微服务开源生态
  10. PHP的魔术常量(常用八大常量)