幻影学霸刘 @ 2019-09-21 14:52:55
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
string a;
int c[512],t=0;
for(int i=0;i<512;i++)
{
c[i]==0;
}
cin>>a;
for(int i=0;i<a.size()-1;i++)
{
string s;
cin>>s;
a+s;
}
bool b=a[0]-'0';
for(int i=0;i<a.size();i++)
{
if(b==a[i]-'0')
{
for(int j=i+1;a[j]-'0'==b;j++)
{
c[t]++;
}
t++;
}
b++;
}
cout<<t<<" ";
for(int i=0;i<t;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
by awa再也不水贴 @ 2019-09-21 15:00:11
答案?
by awa再也不水贴 @ 2019-09-21 15:00:57
万能头不好吗?
by 幻影学霸刘 @ 2019-09-21 15:01:38
by 幻影学霸刘 @ 2019-09-21 15:01:52
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string a;
int c[512],t=0;
for(int i=0;i<512;i++)
{
c[i]=0;
}
cin>>a;
for(int i=0;i<a.size()-1;i++)
{
string s;
cin>>s;
a+=s;
}
bool b=a[0]-'0';
for(int i=0;i<a.size();i++)
{
if(b==a[i]-'0')
{
int j;
for(j=i+1;a[j]-'0'==b;j++)
{
c[t]++;
}
t++;
}
if(b==0)
{
b=1;
}
else
{
b=0;
}
}
cout<<t<<" ";
for(int i=0;i<t;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
by T1anBooy @ 2019-09-21 15:07:04
#include <bits/stdc++.h>
using namespace std;
int num, same;
string a;
int main() {
cin >> a;
int n;
n = a.length();
cout << n << " ";
for (int i = 1; i <= n; i ++) {
same = a[0] - '0';
for (int j = 1; j < n; j ++) {
if (a[i] - '0' == same) num ++;
if (a[i] - '0' != same) {
cout << num << " ";
num = 1;
same = a[i];
}
}
cin >> a;
}
return 0;
}
by awa再也不水贴 @ 2019-09-21 15:08:36
初始化可以
int c[512]={0},t=0;
by 幻影学霸刘 @ 2019-09-21 15:10:32
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string a;
int c[512],t=0;
for(int i=0;i<512;i++)
{
c[i]=0;
}
cin>>a;
for(int i=0;i<a.size()-1;i++)
{
string s;
cin>>s;
a+=s;
}
bool b=a[0]-'0';
for(int i=0;i<a.size();i++)
{
if(b==a[i]-'0')
{
int j;
for(j=i+1;a[j]-'0'==b;j++)
{
c[t]++;
}
i=j;
t++;
}
if(b==0)
{
b=1;
}
else
{
b=0;
}
}
cout<<t<<" ";
for(int i=0;i<t;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
by T1anBooy @ 2019-09-21 15:12:08
#include <bits/stdc++.h>
using namespace std;
int num, same;
string a;
int main() {
cin >> a;
int n;
n = a.length();
cout << n << " ";
for (int i = 1; i <= n; i ++) {
same = a[0] - '0';
for (int j = 1; j < n; j ++) {
if (a[j] - '0' == same) num ++;
if (a[j] - '0' != same) {
cout << num << " ";
num = 1;
same = a[j] - '0';
}
}
cin >> a;
}
return 0;
}
by 幻影学霸刘 @ 2019-09-21 15:27:06
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
string a;
int c[512],t=0;
for(int i=0;i<512;i++)
{
c[i]=0;
}
cin>>a;
for(int i=0;i<a.size()-1;i++)
{
string s;
cin>>s;
a+=s;
}
cout<<a.size()<<" ";
if(a[0]=='1')
{
cout<<"0";
}
int cnt=1;
bool b=a[0]-'0';
for(int i=0;i<a.size();i++)
{
if(a[i]==a[i-1])
{
cnt++;
}
else
{
cout<<cnt<<" ";
cnt=1;
}
}
cout<<cnt;
return 0;
}
by T1anBooy @ 2019-09-21 15:33:53
#include <bits/stdc++.h>
using namespace std;
int num;
string a, temp;
int main() {
while (cin >> temp)
a += temp;
cout << temp.length() << " ";
int n;
if (a[0] == '1') cout << "0";
n = a.length();
num = 1;
for (int j = 1; j < n; j ++) {
if (a[j] == a[j - 1]) num ++;
if (a[j] != a[j - 1]) {
cout << num << " ";
num = 1;
}
}
return 0;
}