本人一个智障,string怎么用都不记得了....
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
string s[15];
//按键没有坏之前
s[1] = " "; s[2] = "abc"; s[3] = "def";
s[4] = "ghi"; s[5] = "jkl"; s[6] = "mno";
s[7] = "pqrs"; s[8] = "tuv"; s[9] = "wxyz";
string c[15]; //坏了之后的按键
int n[15]; //一开始输入的数字
string str; //要输入的字符串
int main () {
for (int i = 1; i <= 9; ++i)
cin >> n[i];
for (int i = 1; i <= 9; ++i)
c[i] = s[ n[i] ]; //键盘坏了,改变
cin >> str;
int last_e; //方便特判输出'#'
for (int k = 0; k < str.length(); ++k) {
char now = str[k];
int e, l; //e代表是哪个按键,l是输出几次
for (int i = 1; i <= 9; ++i) {
for (int j = 0; j < c[i].length(); ++i) {
if (c[i][j] == now) {
e = i; l = j + 1;
break;
}
}
}
if (e == last_e) {
cout << '#';
}
for (int i = 1; i <= l; ++i)
cout << e;
last_e = e;
}
return 0;
}
您看前面的那块赋值,就是s[1] = *** ,s[2] = *** 那里报错了,蒟蒻没看懂报错信息?
大佬指点一下哪里错了啊