Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- #include <stdlib.h>
- #include <stdio.h>
- struct element {
- int elem, nord, south, east, west; //, check;
- };
- int** m;
- int* vect;
- int n,k;
- struct element a;
- struct element first;
- int main(int argc, char** argv) {
- int i,j;
- n = 6;//atoi(argv[1]);
- // k = atoi(argv[2]);
- m = (int**)malloc(n*sizeof(int));
- for(i=0;i<n;i++){
- m[i] =malloc(n*sizeof(int));
- for(j=0;j<n;j++){
- m[i][j] = rand()%100;
- printf("%d ",m[i][j]);
- }
- printf("\n");
- }
- a = (struct element*) malloc(n*sizeof(struct element));
- for (i=0;i<n;i++){
- for(j=0;j<n;j++) {
- a[i]->elem = m[i][j]; //31
- if (i==1) a[i]->nord = -1; //32
- else a[i]->nord = m[i-1][j]; //33
- if(i==n) a[i]->south = -1; //34
- else a[i]->south = m[i+1][j]; //35
- if(j==1) a[i]->west = -1; //36
- else a[i]->west = m[i,j-1]; //37
- if (j==n) a[i]->east = -1;
- else a[i]->east = m[i,j+1];
- }
- }
- first = (struct element*)malloc(sizeof(struct element));
- first.elem = a[1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement