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

📄 1.c

📁 C语言成绩管理系统
💻 C
字号:

#include "stdio.h"
#define NULL 0
struct node
{  int data;
   struct node *next;
 };

struct node *creat();
struct node *insert(struct node *head,int value)
{
   struct  node *new ,*p,*q;
   new=(struct node *)malloc(sizeof(struct node));
   new ->data=value;
   p=head;
     if(head==NULL)
       { head=new;
         new->next=NULL;
        }
     else
       { while ((p->next!=NULL)&&(p->data<value))
          { q=p;p=p->next;}
          if(p->data>=value)
          { if(head==p)
            { new->next=head;
              head=new;
             }
             else
                 { q->next=new;
                   new->next=p;
                  }
           }
           else
           { p->next=new;
             new->next=NULL;
            }
        }
        return(head);
}
void main()
{
  struct node *q;
  int value;
  q=creat();
  printf("请输入要插入的整数:");
  scanf("%d",&value);
  q=insert(q,value);
  printf("The data of link =:\n");
  while(q!=NULL)
    {
       printf("%d\t",q->data);
       q=q->next;
     }
  printf("\n");
  getch();
}

⌨️ 快捷键说明

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