1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | #include<civlc.h>
|
|---|
| 2 |
|
|---|
| 3 | $input int N;
|
|---|
| 4 | $assume N > 0 && N <= 2;
|
|---|
| 5 |
|
|---|
| 6 | typedef struct Node {
|
|---|
| 7 | double value;
|
|---|
| 8 | struct Node* next;
|
|---|
| 9 | } Node;
|
|---|
| 10 |
|
|---|
| 11 | void main() {
|
|---|
| 12 | $heap h;
|
|---|
| 13 | Node* head;
|
|---|
| 14 | Node* current = (Node *) $malloc(&h, sizeof(Node));
|
|---|
| 15 | Node final;
|
|---|
| 16 |
|
|---|
| 17 | head = current;
|
|---|
| 18 | head->value = 0.0;
|
|---|
| 19 | {
|
|---|
| 20 | Node* newNode = (Node *) $malloc(&h, sizeof(Node));
|
|---|
| 21 |
|
|---|
| 22 | newNode->value = 2.71828;
|
|---|
| 23 | current->next = newNode;
|
|---|
| 24 | current = newNode;
|
|---|
| 25 | }
|
|---|
| 26 | current->next = NULL;
|
|---|
| 27 | final = *head;
|
|---|
| 28 | while (final.next != NULL) {
|
|---|
| 29 | final = *(final.next);
|
|---|
| 30 | }
|
|---|
| 31 | $assert final.value == 2.71828;
|
|---|
| 32 | $assert final.value == current->value;
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.