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

📄 smalarg.c

📁 splitting of linked list
💻 C
字号:
#include<stdio.h>
#include<conio.h>
#include"treelib.c"

int small(node **root)
{
 node *temp;
 temp=*root;
 if(temp==NULL)
 {
   printf("tree is empty\n");
   return NULL;
 }
 else
 {
  while(temp->left!=NULL)
    temp=temp->left;
  return(temp->info);
 }
}

int large(node **root)
{
 node *temp;
 temp=*root;
 if(temp==NULL)
 {
   printf("tree is empty\n");
   return NULL;
 }
 else
 {
  while(temp->right!=NULL)
    temp=temp->right;
  return(temp->info);
 }
}

void main()
{
  node *s;
  int i,n;
  char ch;
  clrscr();
  do
  {
    printf(" 1->insertion \n 2->smallest ele\n 3->largest ele\n 4->exit\n");
    scanf("%d",&n);
    switch(n)
    {
     case 1: create(&s);
		do
		{
			printf("insert data : ");
			scanf("%d",&i);
			insert(&s,i);
			printf("again : ");
			fflush(stdin);
			scanf("%c",&ch);
		}
		while(ch=='y');
	     break;
     case 2: i = small(&s);
	     printf("smallest ele : %d \n",i);
	     break;
     case 3: i = large(&s);
	     printf("largest ele : %d \n",i);
	     break;
     case 4: exit();
	     break;
  }
 }
 while(n!=4);
 getch();
}


⌨️ 快捷键说明

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