【Educational Codeforces Round 2A】【模拟】Extract Numbers 分离数串和字符串
来源:互联网 发布:广州市失独数据 编辑:程序博客网 时间:2024/06/06 07:08
//http://blog.csdn.net/snowy_smile#include<stdio.h>#include<string.h>#include<ctype.h>#include<math.h>#include<iostream>#include<string>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T> inline void gmax(T &a,T b){if(b>a)a=b;}template <class T> inline void gmin(T &a,T b){if(b<a)a=b;}const int N=1e5+10,M=0,Z=1e9+7,ms63=1061109567;char s[N];string a,b;int main(){while(~scanf("%s",s)){int l=strlen(s);s[l]=';';int p=0;bool flag=0;a="";int numa=0;b="";int numb=0;for(int i=0;i<=l;++i){if(s[i]==','||s[i]==';'){s[i]=0;if(!flag&&s[p]!=0){if(++numa==1)a+=s+p;else {a+=",";a+=s+p;}}else{if(++numb==1)b+=s+p;else {b+=",";b+=s+p;}}p=i+1;flag=0;}else if(!isdigit(s[i]))flag=1;else if( (i==0||s[i-1]==0) && s[i]=='0'&&isdigit(s[i+1]))flag=1;}if(numa==0)a="-";else a='"'+a+'"';if(numb==0)b="-";else b='"'+b+'"';cout<<a<<endl<<b<<endl;}return 0;}/*【题意】若干个字符串在一行。字符串有数串(无前导零)和其他串,之间用','或';'分隔。让你把两种类型的串在两行分别输出。【类型】模拟【分析】直接模拟即可。1,数串的判定除了数字全为digit外,还要求没有前导零。2,可以用末尾赋值为0的方法做串赋值串合并操作。【时间复杂度&&优化】O(|s|)*/
0 0
- 【Educational Codeforces Round 2A】【模拟】Extract Numbers 分离数串和字符串
- Educational Codeforces Round 2 A. Extract Numbers(模拟)
- Educational Codeforces Round 2 A.Extract Numbers(模拟)
- Educational Codeforces Round 2 A. Extract Numbers
- codeforces Educational Codeforces Round 2 A. Extract Numbers
- Codeforces Educational Codeforces Round 2 A. Extract Numbers
- codeforces 600 A. Extract Numbers(字符串模拟)
- Codeforces 600A Extract Numbers 【模拟】
- CodeForces 600A - Extract Numbers (模拟题)
- codeforces 600A Extract Numbers 模拟
- Educational Codeforces Round 1 (A)模拟
- Educational Codeforces Round 5(A) 模拟
- Educational Codeforces Round 10(A)模拟
- codeforces A.Extract Numbers
- Educational Codeforces Round 13 A Johny Likes Numbers(水题)
- Educational Codeforces Round 1 B.Queries on a String(模拟)
- Educational Codeforces Round 7-A. Infinite Sequence(模拟)
- Educational Codeforces Round 9-A. Grandma Laura and Apples(模拟)
- linux基础之uboot load address、entry point、 bootm address以及kernel运行地址的意义及联系
- 人工很贵的背后是什么?
- 自定义适配器
- 递交人生中的第二份辞职申请
- Java设计模式四: 原型模式(Prototype Pattern)
- 【Educational Codeforces Round 2A】【模拟】Extract Numbers 分离数串和字符串
- Spring MVC设置首页,403,404,500页面
- 关于伪静态学习的一点总结
- mysql绿色版安装问题解决(ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061))
- RFID和NFC有什么区别和关系?
- 闲话Zynq UltraScale+ MPSoC (连载2)——架构和电源要求
- Matlab中Flipdim函数的运用
- 51nod 1449 砝码称重
- OC 循环引用