SHOW:
|
|
- or go back to the newest paste.
| 1 | #include<stdio.h> | |
| 2 | #include<stdlib.h> | |
| 3 | ||
| 4 | struct lista | |
| 5 | {
| |
| 6 | int x; | |
| 7 | struct lista * NEXT; | |
| 8 | }; | |
| 9 | ||
| 10 | void fun(int n) | |
| 11 | {
| |
| 12 | struct lista * pierwsza=(struct lista *)malloc(sizeof(struct lista)); | |
| 13 | struct lista * druga= (struct lista *)malloc(sizeof(struct lista)); | |
| 14 | struct lista * trzecia= (struct lista *)malloc(sizeof(struct lista)); | |
| 15 | struct lista * current= (struct lista *)malloc(sizeof(struct lista)); | |
| 16 | pierwsza->NEXT=druga; | |
| 17 | pierwsza->x=1; | |
| 18 | druga->NEXT=trzecia; | |
| 19 | druga->x=4; | |
| 20 | trzecia->NEXT=pierwsza; | |
| 21 | trzecia->x=7; | |
| 22 | current=pierwsza; | |
| 23 | for(n; n>0; n--) | |
| 24 | {
| |
| 25 | printf("%d",current->x);
| |
| 26 | current=current->NEXT; | |
| 27 | } | |
| 28 | } | |
| 29 | ||
| 30 | int main() | |
| 31 | {
| |
| 32 | int n=10; | |
| 33 | fun(n); | |
| 34 | return 0; | |
| 35 | } |