rt,我调试的时候在 44 行输出了 x[pos] 和 y[pos],结果 x[pos] 有问题,不知道错在哪了,求助!
#include <iostream>
#include <map>
using namespace std;
string mat[15][105][15];
int x[15], y[15];
map<string, int> mp;
int main()
{
int n;
cin >> n;
for (int t = 1; t <= n; t++)
{
string s;
cin >> s;
cin >> x[t] >> y[t];
cout << x[t] << " " << y[t] << "\n";
mp[s] = t;
for (int i = 1; i <= x[t]; i++)
{
for (int j = 1; j <= y[t]; j++)
{
cin >> mat[t][i][j];
}
}
}
int T;
cin >> T;
string s;
getline(cin, s);
while (T--)
{
getline(cin, s);
int id = s.find(" from ");
int id1 = s.find(" where ");
int id2 = s.find("=");
string col = s.substr(7, id - 7);
string tbn = s.substr(id + 6, id1 - id - 6);
string hea = s.substr(id1 + 7, id2 - id1 - 7);
string x = s.substr(id2 + 1);
// cout << id << " " << id1 << " " << id2 << " " << col << " " << tbn << " " << hea << " " << x << "\n";
int pos = mp[tbn];
cout << pos << " " << x[pos] << " " << y[pos] << "\n"; // 这里的 x[pos] 有问题
// 没写完
}
return 0;
}