Jaa*_*nus 3 c++ string visual-studio visual-c++
基本上应该做的是:
1)获取字符串并找到其长度
2)遍历所有元素key并将所有独特成员放入start(playfair密码)
Table::Table(string key) {
int i;
for(i = 0; i < key.length(); i++) {
if(start.find(key[i]) == string::npos) { //start is empty string
start[start.length()] = key[i]; // this line gives error
}
}
}
Run Code Online (Sandbox Code Playgroud)
错误:

因为有效指数范围从0高到length - 1包含.如果要在字符串中添加char,请使用push_back
start.push_back(key[i]); //this will increase the length by 1
Run Code Online (Sandbox Code Playgroud)