-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinked_list_perc.c
More file actions
58 lines (40 loc) · 886 Bytes
/
linked_list_perc.c
File metadata and controls
58 lines (40 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<stdio.h>
#include<stdlib.h>
typedef struct node {
int val;
struct node * next;
} node_t;
// bond percolation in a lattice //
typedef struct vertex {
int coordx;
int coordy;
struct edge * north;
struct edge * south;
struct edge * east;
struct edge * west;
} vertex_t;
typedef struct edge {
int val; //edge open or closed w.p. p
struct vertex * v1;
struct vertex * v2;
} edge_t;
void main(){
node_t * head = NULL;
head = malloc(sizeof(node_t));
head->val = 1;
head->next = malloc(sizeof(node_t));
node_t * current = head;
int count = 0, idx = 0;
while(count < 100){
current->next = malloc(sizeof(node_t));
current->val = idx;
idx++;
printf("%d\n", current->val);
current = current->next;
count++;
}
vertex_t * origin = NULL;
origin = malloc(sizeof(vertex_t));
// its edges are open w.p. p
int p = 0.2;
}