带通配符的数

输入格式

多组数据,每组数据两行,第一行是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;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值