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

📄 9.c

📁 数据结构练习共18道。
💻 C
字号:
#include <stdio.h>
#include<malloc.h>
typedef struct node{
	char Elem;
	struct node *next;
}Lnode;

void main()
{
	char k;
	Lnode *s,*l,*p,*q,*tail;
	s =(Lnode*) malloc(sizeof (Lnode));
	s->Elem=0;
	s->next=NULL;
	printf("Input the first string:");
	k=getchar();
	while(k!=(char)(10))
	{
		p =(Lnode*) malloc(sizeof (Lnode));
		
		p->Elem=k;
		p->next=NULL;

		if (s->next==NULL)
		{
			s->next = p;
			tail=p;
		}
		else
		{tail->next=p;tail=p;}
		k=getchar();
	}

	l =(Lnode*) malloc(sizeof (Lnode));
	l->Elem=0;
	l->next=NULL;
	printf("Input the second string:");
	k=getchar();
	while(k!=(char)(10))
	{
		p =(Lnode*) malloc(sizeof (Lnode));
		
		p->Elem=k;
		p->next=NULL;

		if (l->next==NULL)
		{
			l->next = p;
			tail=p;
		}
		else
		{tail->next=p;tail=p;}
		k=getchar();
	}
	
	p=s->next;
	q=l->next;

	while(p!=NULL&&q!=NULL)
		if(p->Elem==q->Elem)
		{p=p->next;q=q->next;}
		else {printf("Not equal");return;}


	if(p==NULL&&q==NULL)printf("Equal");

	else printf("Not equal");
}

⌨️ 快捷键说明

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