Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void addMid(struct Node *list,int d){
- int c=0;
- struct Node *tmplist=list;
- while(tmplist){
- c++;
- tmplist=tmplist->link;
- }
- int i=1;
- while(list){
- if(i==((c%2)==0?c/2:(c/2)+1)){
- struct Node *tmp=(struct Node*)malloc(sizeof(struct Node));
- tmp->link=list->link;
- tmp->info=list->info;
- list->info=d;
- list->link=tmp;
- return;
- }
- i++;
- list=list->link;
- }
- }
- void search(struct Node *list,int d){
- while(list){
- if(list->info==d){
- printf("%d Found\n",d);
- return;
- }
- list=list->link;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment