题解 | #牛牛的单向链表#

牛牛的单向链表

https://www.nowcoder.com/practice/95559da7e19c4241b6fa52d997a008c4

#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
	int date;
	struct node* next;
}node;
node* creat(int n)
{
	node* head, * p;
	head = (node*)malloc(sizeof(node));
	head->date = 0;
	head->next = NULL;
	p = head;
	for (int i =0; i <n; i++)
	{
		node* newnode = (node*)malloc(sizeof(node));
		scanf("%d", &newnode->date);
		newnode->next = NULL;
		p->next = newnode;
		p = p->next;
	}
	return head;
}
void printnode(node* head)
{
	node* p;
	p = head->next;
	while (p != NULL)
	{
		printf("%d ", p->date);
		p = p->next;
	}
}
int main()
{
	int n=1, i;
	node* head;
	scanf("%d", &n);
	head = creat(n);
	printnode(head);
	return 0;
}

全部评论

相关推荐

我的offer呢😡:这不才9月吗,26到明年毕业前能一直找啊,能拿下提前批,转正的,offer打牌的都是有两把刷子的,为什么非要跟他们比。如果别人是9本硕+金牌+好几段大厂实习呢?如果别人是双非通天代呢?如果别人是速通哥呢?,做好自己就行了,我们做不到他们一样提前杀死比赛,但晚点到终点也没啥关系吧
双非应该如何逆袭?
点赞 评论 收藏
分享
09-28 22:01
已编辑
广西科技大学 IT技术支持
合适才能收到offe...:找桌面运维?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务