Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:看我的行吗?219MSIn Reply To:Accepts了,但是花的时间很多,请问如何优化? Posted by:xiaohao2009 at 2009-04-28 18:09:23 #include <iostream> #include <string.h> using namespace std; int main() { int n,t,i,count; cin>>n; char a[10000],p; while(n--) { cin>>a; t=strlen(a); for(i=0;i<t;i++) { if(a[i]!=a[i+1]) cout<<"1"<<a[i]; else { if(i==t) break; count=1; while(a[i]==a[i+1]) { p=a[i]; count++; i++; } cout<<count<<p; } } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator