阅读程序回答问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include<iostream> #include<vector> #include<algorithm> using namespace std; int f(string x,string y){ int m=x.size(); int n=y.size(); vector<vector<int>>v(m+1,vector<int>(n+1,0)); for(int i=1;i<=m;i++){ for(int j=1;j<=n;j++){ if(x[i-1]==y[j-1]){ v[i][j]=v[i-1][j-1]+1; }else{ v[i][j]=max(v[i-1][j],v[i][j-1]); } } } return v[m][n]; } bool g(string x,string y){ if(x.size() != y.size()){ return false; } return f(x+x,y)==y.size(); } int main(){ string x,y; cin>>x>>y; cout<<g(x,y)<<endl; return 0; } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、f
函数的返回值小于等于 min{n,m}。()
2、f
函数的返回值等于两个输入字符串的最长公共子串的长度。()
3、当输入两个完全相同的字符串时,g
函数的返回值总是 true
。()
4、将第18行中的 v[m][n]
替换为 v[n][m]
,那么该程序()。
5、当输入为 csp-j p-jcs
时,输出为()。
6、当输入为 csppsc spsccp
时,输出为()。