11.c

来自「数据结构练习共18道。」· C语言 代码 · 共 67 行

C
67
字号
#include <stdio.h>
#include<malloc.h>
typedef struct node{
	char Elem;
	struct node *next;
}Lnode;

void main()
{
	char k;
	Lnode *s,*l,*p,*q,*ftail,*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;
			ftail=p;
		}
		else
		{ftail->next=p;ftail=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();
	}
	
	ftail->next=l->next;

	p=s->next;
	printf("\nThe concat string is:");
	while(p!=NULL)
	{
		printf("%c",p->Elem);
		p=p->next;
	}
	
}

⌨️ 快捷键说明

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