xiejinhao @ 2019-03-31 11:18:09
using namespace std; char a[40200]; string s; long long t,e; int main() { getline(cin,s); for(int i=s.length();i<s.length()s.length();i++) { cin>>a[i]; } for(int i=0;i<s.length();i++) { a[i]=s[i]; } cout<<s.length()<<" "; if(a[0]=='0') { for(int i=0;i<s.length()s.length();i++) { if(a[i+1]=='1'||i+1==s.length()s.length()) { cout<<t+1<<" "; t=0; for(int j=i+1;j<s.length()s.length();j++) { if(a[j+1]=='0'||j+1==s.length()s.length()) { cout<<e+1<<" "; e=0; i=j; break; } else e++; } } else { t++; } } } else if(a[0]=='1') { cout<<"0"<<" "; for(int i=0;i<s.length()s.length();i++) { if(a[i+1]=='0'||i+1==s.length()s.length()) { cout<<t+1<<" "; t=0; for(int j=i+1;j<s.length()s.length();j++) { if(a[j+1]=='1'||j+1==s.length()*s.length()) { cout<<e+1<<" "; e=0; i=j; break; } else e++; } } else { t++; } } } return 0; }
by Smile_Cindy @ 2019-03-31 11:19:05
@xiejinhao
希望更丰富的展现?使用Markdown
by xiejinhao @ 2019-03-31 11:24:24
附上代码
#include<iostream>
#include<string>
using namespace std;
char a[40200];
string s;
long long t,e;
int main()
{
getline(cin,s);
for(int i=s.length();i<s.length()*s.length();i++)
{
cin>>a[i];
}
for(int i=0;i<s.length();i++)
{
a[i]=s[i];
}
cout<<s.length()<<" ";
if(a[0]=='0')
{
for(int i=0;i<s.length()*s.length();i++)
{
if(a[i+1]=='1'||i+1==s.length()*s.length())
{
cout<<t+1<<" ";
t=0;
for(int j=i+1;j<s.length()*s.length();j++)
{
if(a[j+1]=='0'||j+1==s.length()*s.length())
{
cout<<e+1<<" ";
e=0;
i=j;
break;
}
else e++;
}
}
else
{
t++;
}
}
}
else if(a[0]=='1')
{
cout<<"0"<<" ";
for(int i=0;i<s.length()*s.length();i++)
{
if(a[i+1]=='0'||i+1==s.length()*s.length())
{
cout<<t+1<<" ";
t=0;
for(int j=i+1;j<s.length()*s.length();j++)
{
if(a[j+1]=='1'||j+1==s.length()*s.length())
{
cout<<e+1<<" ";
e=0;
i=j;
break;
}
else e++;
}
}
else
{
t++;
}
}
}
return 0;
}