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

📄 13.c

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

void main()
{
	char k;int len=0;
	Lnode *s,*l,*p,*q,*tail;
	s =(Lnode*) malloc(sizeof (Lnode));
	s->Elem=0;
	s->next=NULL;
	printf("Input the 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();
	}

	p=s->next;

	while(p!=NULL)
	{
		len++;p=p->next;
	}

	printf("\nThe length of the string is:%d",len);

}

⌨️ 快捷键说明

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