1 条题解

  • 0
    @ 2025-10-8 16:52:15
    #include <cstdio>
    #include <cstring>
    using namespace std;
    const int N = 100005;
    char sa[N], sb[N];
    int sta[N], top = 0;
    
    int main() {
        scanf("%s%s", sa, sb);
        int lena = strlen(sa), lenb = strlen(sb);
        for (int i = 0; i <= lena - lenb; i++) {
            int j = 0;
            while (j < lenb) {
                if (sb[j] != '?' && sa[i + j] != sb[j]) break;
                j++;
            }
            if (j == lenb) sta[++top] = i;
        }
        printf("%d\n", top);
        for (int i = 1; i <= top; i++) printf("%d\n", sta[i]);
        return 0;
    }
    
    • 1

    【字符串基础】子串模糊匹配次数

    信息

    ID
    571
    时间
    1000ms
    内存
    128MiB
    难度
    5
    标签
    递交数
    79
    已通过
    30
    上传者