【发布时间】:2017-09-06 02:58:01
【问题描述】:
我想将数据存储在二维数组 t[0][0] 的第一个索引处的第一个元素中! 我写了这段代码:
int main()
{
string input;
cout << "Enter string of code:\n";
cin >> input;
queue < string > m;
string t[100][3];
while (input != "^")
{
int i = 0;
t[i][0] = input;
m.push(t[i][0]);
if (input == " ")
{
t[i + 1][0];
break;
}
cin >> input;
i++;
}
int c = 1;
while (!m.empty())
{
int i = 0;
t[i][0] = m.front();
string temp;
temp = t[i][0];
t[i][1] = check(temp);
//cout <<c<<" "<<t[i][0]<<" Is: " << t[i][1] << endl;
c++;
m.pop();
i++;
}
cout << endl;
cout << c << " " << t[0][0] << " Is: " << t[0][1] << endl;
system("Pause");
return 0;
}
我对这个说法有疑问
cout
这不会打印数组中的值!
【问题讨论】:
-
你应该在while循环上方声明
int i。 -
@jhnnslschnr 谢谢你的帮助
标签: c++ string loops multidimensional-array