测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A61622. 阅读程序:#include <iostream>

编程题

题目描述

阅读程序:

#include <iostream>
#include <string>
#include <vector>
using namespace std;
 
int f(const string &s, const string &t) {
       int n = s.length(), m = t.length();
       vector<int> shift(128, m + 1); 
       int i, j;
       for (j = 0; j < m; j++)
              shift[t[j]] = m - j;
 
       for (i = 0; i <= n - m; i += shift[s[i + m]]) {
              j = 0;
              while (j < m && s[i + j] == t[j]) j++;
              if (j == m) return i;
       }
 
       return -1;
}
int main() {
       string a, b;
       cin >> a >> b;
       cout << f(a, b) << endl;
       return 0;
}

假设输入字符串由 ASCII 可见字符组成,完成下面的判断题和单选题: