作者在 2010-05-08 15:30:44 发布以下内容
multiple initialization
悬赏分:5 - 解决时间:2009-3-9 11:49
// Note:Your choice is C++ IDE
#include <iostream>
using namespace std;
int main()
{
int array1[2][3] ={1,2,3,4,5};
int array2[2][3] ={{1,2},{4}};
cout<<"array1:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array1[i][j]<<",";
cout<<"array2:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array2[i][j]<<",";
悬赏分:5 - 解决时间:2009-3-9 11:49
// Note:Your choice is C++ IDE
#include <iostream>
using namespace std;
int main()
{
int array1[2][3] ={1,2,3,4,5};
int array2[2][3] ={{1,2},{4}};
cout<<"array1:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array1[i][j]<<",";
cout<<"array2:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array2[i][j]<<",";
return 0;
}
}
提问者: ytianhui - 三级最佳答案检举 把第二个带int的for循环中的int去掉。改后代码如下:
#include <iostream>
using namespace std;
int main()
{
int array1[2][3] ={1,2,3,4,5};
int array2[2][3] ={{1,2},{4}};
cout<<"array1:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array1[i][j]<<",";
cout<<"array2:";
for(i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array2[i][j]<<",";
#include <iostream>
using namespace std;
int main()
{
int array1[2][3] ={1,2,3,4,5};
int array2[2][3] ={{1,2},{4}};
cout<<"array1:";
for(int i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array1[i][j]<<",";
cout<<"array2:";
for(i=0; i<2; ++i)
for(int j=0; j<3; ++j)
cout<<array2[i][j]<<",";
return 0;
}
}