注册 登录
编程论坛 C++教室

[求助]这个二维数组问题运行总是提示有误?...囧

小四 发布于 2007-09-19 20:28, 480 次点击


#include<iostream>

using namespace std;
int main()
{
int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2],i,j;

cout<<"array a:"<<endl;

for (i=0;i<=1;i++)

{for(j=0;j<=2;j++)
{
cout<<a[i][j]<<" ";
b[j][i]=a[i][j];

}
cout<<endl;
}
cout<<"array b:"<<endl;
for(i=0;i<=2;i++)
{
for(i=0;j<=1;j++)

cout<<b[i][j]<<" ";
cout<<endl;
}
return 0;
}


PS:编译后提示

Linking...
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/二维数组程序举例.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.


3Q。

4 回复
#2
reedleaf2007-09-19 20:45

#include<iostream>

using namespace std;
int main()
{
int a[2][3]={{1,2,3},{4,5,6}};
int b[3][2],i,j;

cout<<"array a:"<<endl;

for (i=0;i<=1;i++)

{for(j=0;j<=2;j++)
{
cout<<a[i][j]<<" ";
b[j][i]=a[i][j];

}
cout<<endl;
}
cout<<"array b:"<<endl;
for(i=0;i<=2;i++)
{
for(i=0;j<=1;j++)//for(j=0;j<=1;j++)

cout<<b[i][j]<<" ";
cout<<endl;
}
return 0;
}


编译能通过。

#3
小四2007-09-19 20:58

汗...莫非是由于我使用的是汉化版本的原因?

#4
饿狼传说2007-09-19 21:02
编译通过,但是不能结果
#5
reedleaf2007-09-19 22:40

for(i=0;i<=2;i++)
{
for(i=0;j<=1;j++) //for(j=0;j<=1;j++)

cout<<b[i][j]<<" ";
cout<<endl;
}
return 0;

1