Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- /* run this program using the console pauser or add your own getch, system("pause") or input loop */
- struct element {
- int val;
- struct element *p;
- };
- int main(int argc, char *argv[]) {
- struct element *top, *elem;
- int N=10,i;
- elem=(struct element *)malloc(N*sizeof(struct element));
- srand(time(NULL));
- for (i=0;i<N-1;i++) {
- (elem+i)->val=rand()%100+1;
- (elem+i)->p=(elem+i+1);
- }
- (elem+N-1)->p=elem;
- top=elem;
- while (top) {
- printf("%d",top->val);
- top=top->p;
- getchar();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement