level 1
三月于冬
楼主
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
#include<malloc.h>
#include <time.h>
int food[2];
struct snake
{
int x;
int y;
int life;
struct snake *next;
};
struct snake *createlist(struct snake* head)
{
struct snake* q,*p;
q=(struct snake*)malloc(sizeof(struct snake));
q=head;
q->x=16;q->y=16;q->life=1;
p=(struct snake*)malloc(sizeof(struct snake));
q->next=p;
p->x=16;p->y=15;p->life=1;
p->next=NULL;
return head;
}
void drawdot(int x,int y)
{
setfillcolor(BLUE);
x=(x-1)*20;
y=(y-1)*20;
bar(x,y,x+20,y+20);
}
void drawsnake(struct snake* head)
{
struct snake* p;
p=head;
while(p!=NULL)
{
drawdot(p->x,p->y);
p=p->next;
}
}
int main()
{
initgraph(960,640);
struct snake* head;
createlist(head);
drawsnake(head);
getch();
closegraph();
return 0;
}
2017年07月05日 02点07分
1
#include<stdlib.h>
#include<graphics.h>
#include<malloc.h>
#include <time.h>
int food[2];
struct snake
{
int x;
int y;
int life;
struct snake *next;
};
struct snake *createlist(struct snake* head)
{
struct snake* q,*p;
q=(struct snake*)malloc(sizeof(struct snake));
q=head;
q->x=16;q->y=16;q->life=1;
p=(struct snake*)malloc(sizeof(struct snake));
q->next=p;
p->x=16;p->y=15;p->life=1;
p->next=NULL;
return head;
}
void drawdot(int x,int y)
{
setfillcolor(BLUE);
x=(x-1)*20;
y=(y-1)*20;
bar(x,y,x+20,y+20);
}
void drawsnake(struct snake* head)
{
struct snake* p;
p=head;
while(p!=NULL)
{
drawdot(p->x,p->y);
p=p->next;
}
}
int main()
{
initgraph(960,640);
struct snake* head;
createlist(head);
drawsnake(head);
getch();
closegraph();
return 0;
}