CSDN编程英豪赛第四届初赛

CSDN编程英雄赛第四届初赛

题目地址

#include<string>
#include<iostream>
using namespace std;
int main()
{
	string num1, num2;
	while(cin>>num1>>num2)
	{
		long long count = 0;
		for(int i = 0 ; i < num1.size(); i++)
		{
			char ch1 = num1[i];
			char ch2 = num2[i];
			if('?' == ch1)
			{
				if(count == 0)
					count = '9' - ch2;
				else
					count = count * 10 + '9' - ch2;
			}
			else if(ch1 != ch2)
			{
				int tmpcount = 1;
				if(ch1 > ch2 || count != 0)
				{
					for(int j = i+1 ; j < num1.size() ; j++)
						if('?' == num1[j]) tmpcount *= 10;
				}
				if(ch1 > ch2)
				{
					if(count == 0)
						count = tmpcount;
					else
						count = (count + 1) * tmpcount;
				}
				else
				{
					count *= tmpcount;
				}
				break;
			}
		}
		cout<<count<<endl;
	}
}