⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clinkopr.bak

📁 right threaded binary tree
💻 BAK
字号:
#include<stdio.h>
#include<conio.h>
#include"e:ashu\ashu\clinkl.c"

//concatenation of circular doubly linked list
void concat(node **start1,node **start2)
{
  node *temp;
  char ch;
  printf("first list\n");
  do
  {
   addatend(start1);
   printf("again : ");
   fflush(stdin);
   scanf("%c",&ch);
  }
  while(ch=='y' || ch=='Y');
  printf("second list\n");
   do
  {
   addatend(start2);
   printf("again : ");
   fflush(stdin);
   scanf("%c",&ch);
  }
  while(ch=='y' || ch=='Y');
  printf("first list\n");
   display(start1);
   printf("second list\n");
   display(start2);
   temp=*start1;
   do
     temp=temp->next;
   while(temp->next!=*start1);
   temp->next=*start2;
   (*start2)->prev=temp;
   temp=*start2;
   do
     temp=temp->next;
   while(temp->next!=*start2);
   temp->next=*start1;
   printf("concatenated list\n");
   display(start1);
}

void search(node **start)
{
  node *temp;
  int ele,c=1;
  printf("element : ");
  scanf("%d",&ele);
  temp=*start;
  if(*start==NULL)
  {
     printf("list is empty\n");
     return;
   }
  do
  {
    if(temp->info==ele)
     {
      printf("found at %d position\n",c);
      return;
     }
     else
     {
	temp=temp->next;
	c++;
     }
  }
  while(temp!=*start);
  printf("not found \n");
}


//splitting
void split(node **start)
{
  node *temp,**start1;
  int c=1,pos;
  temp=*start;
  if(temp==NULL)
  {
    printf("list is empty \n");
    return;
  }
  printf("position : ");
  scanf("%d",&pos);
  if(pos>count(start))
  {
   printf("position out of range \n");
   return;
  }
  while(c<pos-1)
  {
    c++;
    temp=temp->next;
  }
  *start1=temp->next;
  temp->next=*start;
  temp=*start1;
  do
   temp=temp->next;
  while(temp->next!=*start);
  (*start1)->prev=temp;
  temp->next=*start1;
  printf("first list is \n");
  display(start);
  printf("second list is \n");
  display(start1);
}


void main()
{
  node *start=NULL,*start1=NULL,*start2=NULL;
  int ele,i,ch;
  char ch2;
  clrscr();
  crtl(&start);
  do
  {
    printf(" the list is \n");
    printf(" 1 for insertion \n 2 for display \n 3 for search \n 4 for splitting \n 5 for concatination\n 6 for exit\n");
    scanf("%d",&ch);
    switch(ch)
    {
      case 1: do
	      {
		addatend(&start);
		printf("again : ");
		fflush(stdin);
		scanf("%c",&ch2);
	      }
	      while(ch2 == 'y' || ch2 == 'Y');
	      break;
      case 2: display(&start);
	      break;
      case 3: do
	      {
		 search(&start);
		 printf("again : ");
		 fflush(stdin);
		 scanf("%c",&ch2);
	      }
	      while(ch2 == 'y' || ch2 == 'Y');
	      break;
      case 4: split(&start);
	      break;
      case 5: concat(&start1,&start2);
	      break;
      case 6: exit();
	      break;
      default:printf("sorry ,invalid choice\n");
	      break;
    }
  }
   while(ch!=6);
getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -