83分求助!
查看原帖
83分求助!
144853
静谧幽蓝楼主2020/9/21 21:24

rt

#include<bits/stdc++.h>
#define Max 0x7fffff
using namespace std;
struct nima{
	char first,second;
	int score,have;
	nima(){}
	nima(char a)
	{
		score= a=='/'? 10:a-'0' ;
		first=a;
		have=1;
	}
	nima(char a,char b)
	{
		first=a;
		second=b;
		score=calculate();
		have=2;
	}
	int calculate()
	{
		if(second=='/') return 10;
		else return first-'0'+second-'0';
	}
}; 
int main()
{
	vector<nima> game;
	nima xx;
	char c,a,b;
	int t=0;
	string s;
	getline(cin,s);
	for(int i=0; i<s.length(); i++)
	{
		c=s[i];
		if(c!=' ')
		{
			t++;
			if(t==1) a=c;
			else b=c;
		}
		else
		{
			if(t==0) continue;
			if(t==1) xx=nima(a);
			else xx=nima(a,b);
			game.push_back(xx);
			t=0;
		}
	}
	if(t!=0)
	{
		if(t==1) xx=nima(a);
		else xx=nima(a,b);
		game.push_back(xx);
	}
	int num=0,last=0;
	vector<int> sum;
	int xxx=game.size();
	for(int i=0; i<min(10,xxx); i++)
	{
		last=num;
		if(game[i].first=='/')
		{
			if(i+1>=xxx) break;
			if(game[i+1].have==2)
			{
				num+=(10+game[i+1].score);
			}
			else
			{
				if(i+2>=xxx) break;
				if(game[i+2].have==1)
				{
					num+=(10+10+game[i+2].score);
				}
				else
				{
					num+=(10+10+game[i+2].first-'0');
				}
			}
		}
		else if(game[i].second=='/')
		{
			if(i+1>=xxx) break;
			if(game[i+1].have==1)
			{
				num+=(10+game[i+1].score);
			}
			else
			{
				num+=(10+game[i+1].first-'0');
			}
		}
		else
		{
			num+=game[i].score;
		}
		cout<<num-last;
		if(i!=min(10,xxx)-1) cout<<" ";
		sum.push_back(num);
	}
	cout<<endl;
	for(int i=0; i<sum.size(); i++)
	{
		cout<<sum[i]<<" ";
	}
	cout<<endl;
	return 0;
}
2020/9/21 21:24
加载中...