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

📄 shiyan1.cpp

📁 符号表查询
💻 CPP
字号:

# include <stdlib.h>
# include <malloc.h>
# include <iostream.h>
# include <conio.h>
#include  <stdio.h>

typedef struct LNode		//define LNode structure
{	int num;
    char character;
	struct LNode *next;
}LNode,*Linklist;

int n=0;
void ListInsert(Linklist L,char ch)  //ListInsert() sub-function
{   
	LNode *p,*q;
    if(L->next==NULL) p=L;
	else p=L->next;
    while(p)       
    {  
		if(ch==p->character)
		{
			printf("Error! the data '%c' has been in the table, it's No %d \n",p->character,p->num);
			return;
		}
		q=p;
		p=p->next;
	

    }

    LNode *s;
    s=(Linklist)malloc(sizeof(LNode));	
    s->num=n+1;
	s->character=ch;
    s->next=NULL;
    q->next=s; 
		n++;
} 

void main()        		//main() function
{    
	 Linklist L;
     LNode *p;
     L=(Linklist)malloc(sizeof(LNode));
     L->next=NULL;
	 char ch='s';
	 int n=0;
	 printf("Please input the datas,end with'$' \n");
	 while(ch!='$')
	 {
	    scanf("%c",&ch);
		getchar();
		ListInsert(L,ch);
	 }  
	 p=L->next;
	 printf("The datas inputed as follow:\n");
	 printf("num   data\n");
	 while(p->next)
	 {
		 printf("%d     %c\n",p->num,p->character);
		 p=p->next;
	 }
}

⌨️ 快捷键说明

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