BUPT数据结构第二次大作业第二题

代码仅供参考,建议读者先自行思考

如下:

#include<stdio.h>
#include<stdlib.h>
typedef struct node {
	struct node* bottom;
	char data;
	int size;
}stack;
typedef struct q_node {
	char data;
	struct q_node* nextPtr;
}list;
typedef struct l_node {
	list* front;
	list* rear;
}queue;
stack* createstack()
{
	stack* a = (stack*)malloc(sizeof(stack));
	a->bottom = NULL;
	a->size = 0;
	return a;
}
stack* create_new_ele(char str)
{
	stack* new_ele = (stack*)malloc(sizeof(stack));
	new_ele->bottom = NULL;
	new_ele->data = str;
	return new_ele;
}
void push(stack* a, stack* b)
{
	b->bottom = a->bottom;
	a->bottom = b;
	a->size++;
}//栈的建立
queue* createqueue()
{
	list* new_ptr = (list*)malloc(sizeof(list));
	new_ptr->nextPtr = NULL;
	queue* new_q = (queue*)malloc(sizeof(queue));
	new_q->front = new_q->rear = new_ptr;
	return new_q;
}
list* create_new_data(char str)
{
	list* new_node = (list*)malloc(sizeof(list));
	new_node->data = str;
	return new_node;
}//队列的建立
int main()
{
	stack* my_stack = createstack();
	queue* my_queue = createqueue();
	char t;
	while ((t = getchar()) != '#')
	{
		push(my_stack, create_new_ele(t));
		my_queue->rear->nextPtr = create_new_data(t);
		my_queue->rear = my_queue->rear->nextPtr;
	}
	int flag = 1;
	while (my_stack->bottom != NULL)
	{
		if (my_stack->bottom->data != my_queue->front->nextPtr->data)
		{
			flag = 0;
			break;
		}
		else
		{
			my_stack = my_stack->bottom;
			my_queue->front = my_queue->front->nextPtr;
		}
	}
	if (flag == 1)	printf("Yes\n");
	else printf("No\n");
	return 0;
}

BUPT(北京邮电大学)大一下学期的数据结构课程是计算机专业非常重要的一门课程。数据结构是计算机科学的基础之一,是对数据的存储、检索、组织和处理的方式和原则的学习。在这门课程中,我们学习了数组、链表、栈、队列、树、图等常见的数据结构,并掌握了它们的基本原理、实现方法以及应用场景。通过学习数据结构,我们能够更加深入地理解算法和程序设计,并且能够在实际的软件开发中更加高效地运用数据结构来解决问。 在数据结构课程中,我们除了理论知识的学习,也进行了大量的实践操作,通过编程实践来加深对数据结构的理解和掌握。我们使用C++语言来实现不同的数据结构,并且进行了相关的调试和测试。通过实际编程的训练,我们不仅能够加深对数据结构的理解,还可以提高自己的编程能力和问解决能力。 这门课程的学习不仅仅是为了考试,更重要的是为了将来的学习和工作打下坚实的基础。数据结构是计算机科学的核心知识之一,对于我们作为计算机专业的学生来说,精通数据结构是至关重要的。通过学习数据结构课程,我们能够为以后的专业课程和实际工作奠定坚实的基础,为我们以后的发展打下坚实的基础。因此,我们会全力以赴地学习这门课程,努力掌握数据结构的核心知识和编程技能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值