Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main(){
  5.     struct t_t {
  6.         struct t_t* next;
  7.         struct t_t* prev;
  8.         int i;} ;
  9.     typedef struct t_t t;
  10.     int i,size;
  11.     t *tmp;
  12.  
  13.     t *list=NULL;
  14.  
  15.     for(i=0;i<100000;i++){
  16.         size=10+rand()%990;
  17.         tmp=malloc(size);
  18.         tmp->i=size;
  19.         if(list==NULL){
  20.             tmp->next=tmp;
  21.             tmp->prev=tmp;
  22.             list=tmp;
  23.             }
  24.         else{
  25.             tmp->next=list;
  26.             tmp->prev=list->prev;
  27.             (list->prev)->next=tmp;
  28.             list->prev=tmp;
  29.             }
  30.         }
  31.  
  32.     // пробежка по списку и вывод
  33.     tmp=list;
  34.     do{
  35.         printf("%d\n",tmp->i);
  36.         tmp=tmp->next;
  37.         }while(tmp!=list);
  38.  
  39.    
  40.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement