📄 link_snake.c
字号:
#include <stdio.h>
#include <stdlib.h>
#include "link_snake.h"
struct body *creat()
{
struct body *head,*p1;
p1=(struct body *)malloc(LEN_STR);
p1->x=12;
p1->y=12;
p1->next=NULL;
head=p1;
}
void insert(struct body *head,int x_value,int y_value)
{
struct body *p1;
p1=head;
while (p1->next!=NULL)
p1=p1->next;
p1->next=(struct body *)malloc(LEN_STR);
p1=p1->next;
p1->x=x_value;
p1->y=y_value;
p1->next=NULL;
}
void born_snake(struct body *head)
{
insert(head,12,13);
insert(head,12,14);
insert(head,12,15);
}
/*
In this funcation : do not care last node !!!
*/
int seek_snake(struct body *head,int x_value,int y_value)
{
struct body *p1=head;
while(p1->next!=NULL)
{
if (p1->x==x_value&&p1->y==y_value) {
return 1;
}
p1=p1->next;
}
return 0;
}
struct body *last_node(struct body *head)
{
struct body *p1=head;
while(p1->next!=NULL)
p1=p1->next;
return p1;
}
void increase_snake(struct body *head ,int x_value,int y_value)
{
struct body *p1=head;
while(p1->next!=NULL)
p1=p1->next;
p1->next=(struct body *)malloc(LEN_STR);
p1=p1->next;
p1->x=x_value;
p1->y=y_value;
p1->next=NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -