link.cpp

来自「Stack, queue, sorting exmaples in C/C++.」· C++ 代码 · 共 53 行

CPP
53
字号
#include<stdio.h>
#include<conio.h>
#include<iostream.h>

struct node{
	int item;
	struct node *next;
	};

typedef struct node NADE;
NADE *start,*cur;

void create()
{
   int i;
   cur=new node;

   printf("enter the num");
   scanf("%d",&i);
   cur->item=i;
   start=cur;
   scanf("%d",&i);

while(i!=-99)
   {
    cur->next=new node;
    cur=cur->next;
    cur->item=i;
    scanf("%d",&i);
    }
cur->next=NULL;
cur=start;
}

void display()
{
 NADE *nod=start;
 while(nod!=NULL)
 {
  printf("[%d] =>",nod->item);
  nod=nod->next;
  }
  printf("NULL");
  }

  void main()
  {
    create();
    display();
    getch();
    }

⌨️ 快捷键说明

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