鉴于:
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8
Run Code Online (Sandbox Code Playgroud)
给定一个chunksize CS,我想将2d数组(struct MATRIX)拆分为struct MATRIX数组:假设cs为2,答案是
Seg[0]:
1 2
1 2
1 2
Seg[1]:
3 4
3 4
3 4
....
Seg[3]:
7 8
7 8
7 8
Run Code Online (Sandbox Code Playgroud)
这是我的Matrix Struct:
typedef struct MATRIX {
int nrow;
int ncol;
int **element;
} MATRIX;
Run Code Online (Sandbox Code Playgroud)
这是分离它们的功能:
void SegmentMatrix(MATRIX input,MATRIX* segs,int Chunksize, int p) {
int i,j,r;
//Allocate segs
for (i …Run Code Online (Sandbox Code Playgroud) 当我尝试编译我的代码时,我得到以下错误:
error #2168: Operands of '=' have incompatible types 'char [255]' and 'char *'.
error #2088: Lvalue required.
Run Code Online (Sandbox Code Playgroud)
我得到这些错误的同一行(即1044),并在多行,所以我通过修复一个我可以修复其他人,所以让我复制你的代码.你可以跳过并且只读取注释以**开头的行只是为了让它更容易:)并以< - 结束我希望代码注释为你提供良好的服务:首先让我从定义类型PRINTOPT开始
typedef struct {
//UsePl signifies if the user would like to see the graphs without having to export data
//Thanks to PlPlot library.
int usePl;
//Feel free to customize and add to this struct
//for any simulation program you create.
//---- Note2self: probably change the graph bool to an array,
//as later you will have to print around 20 …Run Code Online (Sandbox Code Playgroud)