为何本机是对的,但过不了
查看原帖
为何本机是对的,但过不了
38183
sy_whwh楼主2020/6/18 22:35
#include<iostream>
#include<string>
using namespace std;
int main ()
{
	
	int a[201]={0},b[1];
	int ta=0,ts=0,m,k,n;
	string s1;
	getline (cin,s1);
	n=s1.length();
	k=0;
	for (int i=0;i<n;i++)
	{
		if (s1[i]-48==k)
			ts++;
		else
		{
			a[ta]=ts;
			ta++;
			ts=1;
			k=1-k;
			}	
	}
	n--;
	while (n)
	{
		getline (cin,s1);
		for (int i=0;i<s1.length();i++)
		{
		if (s1[i]-48==k)
			ts++;
		else
		{
			a[ta]=ts;
			ta++;
			ts=1;
			k=1-k;
			}	
	}
	n--;
	}
	a[ta]=ts;
	cout<<s1.length()<<" ";
	for (int i=0;i<=ta;i++)
		cout<<a[i]<<" ";
}

输入: 11111 00100 11111 00100 11111 输出:5 0 5 2 1 2 5 2 1 2 5 本机DEV测试没有问题,但是测试为0分.不知如何修改,请大家看看.谢谢

2020/6/18 22:35
加载中...