输入格式
多组数据,每组数据两行,第一行是W,第二行是X,它们长度相同。在[1..10]之间.
输出格式
每行一个整数表示结果。
输入样例
36?1?8
236428
8?3
910
?
5
输出样例
100
0
4
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
double check(char str1[],char str2[],int count)
{
double output=0;
char *p,*q;
char *str3=(char *)calloc(10,sizeof(char));
p=str1;
q=str2;
while(*p)
{
if(*p=='?')
{
output+=
(9.0-(double)*q+48)*pow(10,(double)count-1.0);
p++;q++;
output+=check(p,q,count-1);
break;
}
else if(*p==*q){p++;q++;}
else if(*p>*q)
{
output+=pow(10.0,(double)count);
break;
}
else {output+=0.0;break;}
}
return output;
}
int main()
{
char *str1=(char *)calloc(20,sizeof(char));
char *str2=(char *)calloc(20,sizeof(char));
char *p,*q;
int i=0,count=0;
double output=0.0;
while(cin>>str1)
{
cin>>str2;
p=str1;
while(*p)
{
if(*p++=='?'){count++;}
}
cout.precision(1e9);
cout<<check(str1,str2,count)<<endl;
i++;
memset(str1,0,20);
memset(str2,0,20);
count=0;
output=0;
}
return 0;
}