69,371
社区成员
发帖
与我相关
我的任务
分享
// 两个二维数组a、b,分别是10*10和4*4,并对两个数组进行了赋值
int **a,**b;
a=new int*[10];b=new int*[4];
for(int i=0;i<10;i++)a[i]=new int[10];
for(int i=0;i<4;i++)b[i]=new int[4];
for(int i=0;i<10;i++)
for(int j=0;j<10;j++)
a[i][j]=i+j;
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
b[i][j]=i+j;
// 现在想把4*4数组b的值来更新10*10数组a中的值,例如:数组a的原始值为:
// 0 1 2 3 4 5 6 7 8 9
// 1 2 3 4 5 6 7 8 9 10
// 2 3 4 5 6 7 8 9 10 11
// 3 4 5 6 7 8 9 10 11 12
// . . . . . . . . . . .
// 9 10 11 12 13 14 15 16 17 18
//希望结果成为:
// 0 1 2 0 1 2 3 7 8 9
// 1 2 3 1 2 3 4 8 9 10
// 2 3 4 2 3 4 5 9 10 11
// 3 4 5 3 4 5 6 11 12 13
// . . . . . . . . . . .
// 9 10 11 12 13 14 15 16 17 18
#include <boost/assign/std/vector.hpp> // for 'operator+=()'
using namespace std;
using namespace boost::assign; // bring 'operator+=()' into scope
{
vector<int> values;
values += 1,2,3,4,5,6,7,8,9; // insert values at the end of the container
}