C++实现

    for (int i = 0;i<lena;i++) {
        int j = 0, k = i;
        while (A[k] == B[j]) {
            j++;
            k++;
        }
        if (B[j] == '\0') {
            return i;
        }
    }
    return -1;