编程小游戏(编程小游戏简单又好玩)

编程小游戏(编程小游戏简单又好玩)缩略图

帮忙编个c语言的小游戏

帮忙编个c语言的小游戏

#include “stdio.h”#include “math.h”#include “string.h”#include “stdlib.h”#define SIZE 5void main(){int answer[SIZE], guess[SIZE], a=1, b , times=0, i,j ,flag, f;char c[SIZE+1]; puts ( ” 猜数字游戏 0.001版 “);

//随机生成一个4位不同数字的数字for( i=0; i

for (j=0; j

printf(“请输入一个每一位数字都不同的%d位数\n”, SIZE);

for( flag=1; flag<=30; flag++) //设置最高的猜测次数。

{ a=0; b=0;times++;printf(“第 %d 次 : “, times); //提示这是第几次猜数字

//猜数字do{i=2;gets(c); //获取一个字符串

//通过strlen函数判断字符串的长度是否是4if (strlen(c) !=SIZE ) { puts(“\t输入数字长度不对,请重新输入”); i=0; }

//判断是否有重复数字 if (i !=0) {

for (j=0; j=’0′ && c[i]<='9' )guess[i]=c[i]-'0'; //将字符数组c[i]中的字符转化为数字数组 guess[i]中的数字

else { puts(“\t含有非法数字,请重新输入”); i=0; break; }}}

}while(i!=SIZE);

//比较数字 如果有相同数字,则判断位置是否相同。同位置则a+1,反之b+1

for(i=0; i

if (a==SIZE) { printf(“恭喜,你猜中了\n “); break;} else printf(“猜中 %d个数,%d 个数完全正确  %d 个数位置错误\n\n”, a+b,a,b);

}

}

类似于robocode,codetank的编程游戏都有哪些

类似于robocode,codetank的编程游戏都有哪些

codewar大约是这个名字.. 还有一个,最近才发现的,codecombat挺有意思的小游戏.

C语言编程:剪刀石头布的小游戏

C语言编程:剪刀石头布的小游戏

原创:

TC2.0以及gcc 编译通过

/*=======================================================

*Author :wacs5

*Date :20100601(YYYYMMDD)

*Function :剪刀石头布

*=======================================================*/

#include <stdio.h>

#include <conio.h>

#include <stdlib.h>

#include <time.h>

int main()

{

char name[4][15]={“”,”scissors”,”stone”,”cloth”};

int x[2];

int i;

srand(time(NULL));

for (i=0;i<10;i++) /*10 times game*/

{

x[0]=1+rand()%3; /*generate a number from 1 to 3*/

x[1]=1+rand()%3; /*generate another number from 1 to 3*/

printf(“A=%-12sB=%-12s\t”,name[x[0]],name[x[1]]);

if (x[0]==x[1])

printf(“draw\n”); /*和*/

else if (x[0]%3+1==x[1]) /*lost*/

printf(“lost\n”);

else /*win*/

printf(“win\n”);

}

getch();

return 0;

}

C语言编写小游戏,求指导

写东本,主要在于思路,做之前,先把思路整好,我先给你开个头吧 当点击开始后,就开始记时,下东西的速度,与时间成正比,记时越长,速度越快,然后以左右键来控制躲避物的方向,移动的速度就发按键和释放键的时间成正比,按的时候越长,移动的速度也就越快.当掉落物品的X,Y键复重时,则判定游戏结束. 再加一点,这个游戏,一定是多线程的,你不要做成单线程的了,点开始的时候,就要创建多线程了.如果需坚持的时候越长,掉落的物品越多的话,那么记得也得和多线程成正比 希望对你有用

编程小游戏过程

做小游戏就3个概念 1.美工 2.设计 3.编程 这些的确都不难做,但是要做一个小游戏就要按照上面一步一步来.例如上网上学习啦,但是我个人认为自己研究比较深入了解一些,再说做个小游戏谈何容易啊?如果是来来不得上面那一套,只能修改游戏了. 1.下载flash8 2.下载硕思闪客精灵 破解版 还有,做flash游戏的(游戏中国,AGAME)都去专业部门学习的 FLASH可以做到你意想不到的游戏,只要你有这能力, 你可以用RPG MAKER XP,RPG MAKER VX来试试做, 这个你可以去幻想森林论坛看看. 另外还有专门制作格斗游戏的,3D游戏的软件等等.

C++:趣味编程实现一个小游戏

#include”stdio.h”

#define N 17

void main(){

int a,b,temp,i,j,k,l,m,n;

int num[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};

int *ptr;

printf(“开始元素序号:”);

scanf(“%d”,&a);

printf(“报几出列:”);

scanf(“%d”,&b);

ptr=&num[a-1];

for(i=0;i

for(j=0;j

if(ptr>&num[N-1-i]){

ptr=num;

}

ptr++;

if(ptr>&num[N-1-i]){

ptr=num;

}

}

temp=*ptr;

m=ptr-&num[0];

n=&num[N-1]-ptr;

for(k=m;k

num[k]=num[k+1];

}

num[N-1]=temp;

}

for(l=0;l

printf(“%d\t”,num[l]);

}

printf(“\n”);

}

C语言程序小游戏—-一条龙游戏设计

#include

#include

#include

#include

using namespace std;

typedef __int64 BigInteger;

typedef unsigned int Index;

typedef double Number;

class CombinationIterator

{

vector mCurrent;

Index mN;

Index mM;

static BigInteger factorial( Index n )

{

BigInteger fact = 1;

for( Index i = 2; i <= n; ++i )

fact *= i;

return fact;

}

public:

CombinationIterator(): mN( 0 ), mM( 0 )

{}

CombinationIterator( Index n, Index m )

: mN( n ), mM( m ),

mCurrent( (vector::size_type) m )

{

if( m > n || n < 1 || m < 1 )

throw 1;

for( Index i = 0; i < m; ++i )

mCurrent[ i ] = i;

}

void operator ++ ()

{

if( mM == 0 )

throw 1;

if( mCurrent[ 0 ] == mN – mM )

{

mN = mM = 0;

return;

}

Index i = mM – 1;

while( mCurrent[ i ] == mN – mM + i )

–i;

mCurrent[ i ] = mCurrent[ i ] + 1;

for( Index j = i + 1; j < mM; ++j )

mCurrent[ j ] = mCurrent[ i ] + j – i;

}

const vector& operator* () const

{

return mCurrent;

}

bool operator == ( const CombinationIterator& that ) const

{

if( mM == that.mM && mM == 0 )

return true;// both end

return mM == that.mM && mN == that.mN && mCurrent == that.mCurrent;

}

bool operator != ( const CombinationIterator& that ) const

{

return !( *this == that );

}

};

template

class VectorCombinationIterator

{

vector mVector;

Index mCurrentM;

CombinationIterator mIter;

public:

VectorCombinationIterator()

{}

VectorCombinationIterator(const vector& v)

: mVector( v ), mCurrentM( 1 ), mIter( (Index) v.size(), mCurrentM )

{}

void operator ++ ()

{

++mIter;

if( mIter == CombinationIterator() && mCurrentM < mVector.size() )

{

++mCurrentM;

mIter = CombinationIterator( (Index) mVector.size(), mCurrentM );

}

}

pair< vector, vector > operator* () const

{

const vector& current = *mIter;

pair< vector, vector > result;

for( vector::size_type i = 0; i < mVector.size(); ++i )

if( find( current.begin(), current.end(), i ) != current.end() )

result.first.push_back( mVector[i] );

else

result.second.push_back( mVector[i] );

return result;

}

bool operator == ( const VectorCombinationIterator& that ) const

{

if( mIter == that.mIter && mIter == CombinationIterator() )

return true;// both end

return mCurrentM == that.mCurrentM && mVector == that.mVector && mIter == that.mIter;

}

bool operator != ( const VectorCombinationIterator& that ) const

{

return !( *this == that );

}

};

static char gOperatorChars[]={‘+’,’-‘,’*’,’/’};

struct ExpressionItem

{

Number mValue;

char mOperator;

ExpressionItem* mLeftChild;

ExpressionItem* mRightChild;

ExpressionItem(){}

ExpressionItem( Number v, char oper, ExpressionItem* left, ExpressionItem* right )

: mValue( v ), mOperator( oper ), mLeftChild( left ), mRightChild( right )

{}

static vector mPool;

static ExpressionItem* alloc( Number v, char oper, ExpressionItem* left, ExpressionItem* right )

{

mPool.push_back( ExpressionItem( v, oper, left, right ) );

return &*mPool.rbegin();

}

};

vector ExpressionItem::mPool( 1024*1024 );

vector getPossibleResult( const vector& left, const vector& right )

{

vector result;

for( vector::const_iterator liter = left.begin(); liter != left.end() ; ++liter )

for( vector::const_iterator riter = right.begin(); riter != right.end() ; ++riter )

{

result.push_back( ExpressionItem::alloc( (*liter)->mValue + (*riter)->mValue, ‘+’, *liter, *riter ) );

result.push_back( ExpressionItem::alloc( (*liter)->mValue – (*riter)->mValue, ‘-‘, *liter, *riter ) );

result.push_back( ExpressionItem::alloc( (*liter)->mValue * (*riter)->mValue, ‘*’, *liter, *riter ) );

if( (*riter)->mValue != 0.0 )

result.push_back( ExpressionItem::alloc( (*liter)->mValue / (*riter)->mValue, ‘/’, *liter, *riter ) );

}

return result;

}

vector getPossibleResult( const vector& expItems )

{

if( expItems.size() == 1 )

return expItems;

vector result;

VectorCombinationIterator iter( expItems );

while( iter != VectorCombinationIterator() )

{

pair< vector, vector > p = *iter;

if( p.first.size() != 0 && p.second.size() != 0 )

{

vector items = getPossibleResult( getPossibleResult( p.first ),

getPossibleResult( p.second ) );

result.insert( result.end(), items.begin(), items.end() );

}

++iter;

}

return result;

}

vector getPossibleResult( const vector& numbers )

{

vector expItems;

for( vector::const_iterator iter = numbers.begin(); iter != numbers.end(); ++iter )

expItems.push_back( ExpressionItem::alloc( *iter, 0, NULL, NULL ) );

return getPossibleResult( expItems );

}

void printExpression( ExpressionItem* item, char oper, bool isLeftChild )

{

if( item->mLeftChild == NULL )

{

cout<mValue;

}

else if( ( item->mOperator == ‘+’ || item->mOperator == ‘-‘ ) && ( oper == ‘*’ || oper == ‘/’ ) )

{

cout<<"( ";

printExpression( item->mLeftChild, item->mOperator, true );

cout<<" ";

cout<mOperator;

cout<<" ";

printExpression( item->mRightChild, item->mOperator, false );

cout<<" )";

}

else if( !isLeftChild &&

( ( ( item->mOperator == ‘+’ || item->mOperator == ‘-‘ ) && oper == ‘-‘ ) ||

( ( item->mOperator == ‘*’ || item->mOperator == ‘/’ ) && oper == ‘/’ ) ) )

{

cout<<"( ";

printExpression( item->mLeftChild, item->mOperator, true );

cout<<" ";

cout<mOperator;

cout<<" ";

printExpression( item->mRightChild, item->mOperator, false );

cout<<" )";

}

else

{

printExpression( item->mLeftChild, item->mOperator, true );

cout<<" ";

cout<mOperator;

cout<<" ";

printExpression( item->mRightChild, item->mOperator, false );

}

}

void printExpression( ExpressionItem* item )

{

if( item->mLeftChild != NULL )

{

printExpression( item->mLeftChild, item->mOperator, true );

cout<<" ";

cout<mOperator;

cout<<" ";

printExpression( item->mRightChild, item->mOperator, false );

}

else

cout<mValue;

}

int main()

{

for( int i = 1; i <= 10; ++i )

for( int j = 1; j <= 10; ++j )

for( int k = 1; k <= 10; ++k )

for( int l = 1; l <= 10; ++l )

{

if( i > j || j > k || k > l )

continue;

ExpressionItem::mPool.clear();

ExpressionItem::mPool.reserve( 1024*1024 );

vector vn;

vn.push_back( i );

vn.push_back( j );

vn.push_back( k );

vn.push_back( l );

vector exps = getPossibleResult( vn );

for( int m = 0; m < exps.size(); ++m )

if( exps[ m ]->mValue >= 23.999 && exps[ m ]->mValue <= 24.001 )

{

cout<

printExpression( exps[ m ] );

cout<<" = "<mValue<

break;

}

// if( m == exps.size() )

// cout<

}

return 0;

}

用vb编程编一个小游戏

‘窗体添加label1控件,将index属性设置为0,使成为控件数组,再添加timer1控件

Option Explicit

Private Declare Function GetAsyncKeyState Lib “user32” (ByVal vKey As Long) As Integer

Dim m As Integer

Private Sub Form_KeyPress(KeyAscii As Integer)

Dim j As Integer

If KeyAscii = 13 Then

Timer1.Enabled = True

ElseIf KeyAscii = 27 Then ‘ESC暂停

Timer1.Enabled = False

ElseIf Timer1.Enabled = True Then

For j = 0 To 9

If Label1(j).Caption = UCase(Chr(KeyAscii)) Then

m = m + 1

If m = 30 Then Me.Caption = “第1级”

If m = 60 Then Me.Caption = “第2级”

If m = 90 Then Me.Caption = “第3级”

Label1(j).Top = 0

Exit For

End If

Next

End If

End Sub

Private Sub Form_Load()

Dim i As Integer

For i = 1 To 9

Load Label1(i)

Label1(i).Visible = True

Next

For i = 0 To 9

Label1(i).Top = 0

Next

Timer1.Enabled = False

Timer1.Interval = 100

Label1(0).Caption = “按回车开始游戏”

Me.Caption = “第0级”

End Sub

Private Sub Timer1_Timer()

Static n As Integer

Dim i As Integer

If n = 10 Then

MsgBox “游戏结束”

Timer1.Enabled = False

End If

For i = 0 To 9

If Label1(i).Top > Form1.Height Then

Label1(i).Top = 0

Randomize

Label1(i).Caption = Chr(Int(Rnd * 26 + 65))

n = n + 1

ElseIf Label1(i).Top = 0 Then

Randomize

Label1(i).Caption = Chr(Int(Rnd * 26 + 65))

Label1(i).Top = Label1(i).Top + 100

Else

Label1(i).Top = Label1(i).Top + 100

End If

Next

End Sub

小游戏C语言程序

展开全部

呵呵~~查了库函数,我知道怎么编了,等我下,抓紧编程中….

哎,编了一天,终于大功告成!!!有疑问之处qq我:281754179

#include

#include //用来计算时间差

#include //rand(),srand()函数所需头文件

#include //getch()所需函数

#include

int i=0;

int*down_i,*up_i;

time_t first_time, end_time;//time_t在time.h中被定义为long型

int main()

{

void pai_hang_bang(FILE*,char**,double*,time_t);//排行榜

int j;

int rand_i,guess;

char **nickname;

double *time_sum;

FILE*fp;

if((fp=fopen(“d:/游戏排行榜.txt”,”a+”))==NULL)//防错处理

{

puts(“error!”);

exit(1);//异常退出

}

//下面为申请动态数组

nickname=(char**)malloc(1*sizeof(char*));

nickname[0]=(char*)malloc(555*sizeof(char));

down_i=(int*)malloc(1*sizeof(int));

up_i=(int*)malloc(1*sizeof(int));

time_sum=(double*)malloc(1*sizeof(double));

restart://goto的标记

puts(“输入你的昵称:”);

fflush(stdin);//清空输入流,避免gets函数受到空格等因素影响

gets(nickname[i]);

puts(“你想猜的数字范围是?(用空格分开):”);

while((scanf(“%d%d”,&down_i[i],&up_i[i])==0)||down_i[i]>up_i[i])//如果输入有误,scanf函数将返回0

{

printf(“输入错误,请重新输入(按任意键继续):”);

getch();

printf(“\r \r”);//清除上面这一句话

fflush(stdin);//清空输入流,避免getch()、及scanf()函数受到空格等因素影响

}

rand_i=rand()%(up_i[i]-down_i[i]+1)+down_i[i];//生成down_i~up_i之间的随机数

printf(“按任意键开始(按下后即进行游戏计时):”);

getch();

printf(“\r \r”);//清除上面这一句话

first_time=time(NULL);//记录游戏开始时间

printf(“请输入一个数(%d~%d):\n”,down_i[i],up_i[i]);

while(1)

{

scanf(“%d”,&guess);

if(guess>rand_i)

puts(“大了”);

else if(guess puts(“小了”);

else

{

puts(“恭喜你,答对了!(按Esc键退出,其他键继续)”);

break;

}

}

end_time=time(NULL);//记录游戏结束时间

time_sum[i]=difftime(end_time,first_time);//difftime()函数用来得到时间差

printf(“本轮游戏时间为: %.0Lf seconds”,time_sum[i]);

if(‘\x1b’==getch())//注意这里有getch()

{

pai_hang_bang(fp,nickname,time_sum,end_time);

return 0;

}

system(“cls”);//清除当前屏幕

i++;

//下面为动态扩充数组

nickname=(char**)realloc(nickname,(i+1)*sizeof(char*));

nickname[i]=(char*)malloc(555*sizeof(char));

down_i=(int*)realloc(down_i,(i+1)*sizeof(int));

up_i=(int*)realloc(up_i,(i+1)*sizeof(int));

time_sum=(double*)realloc(time_sum,(i+1)*sizeof(double));

goto restart;

getch();

fclose(fp);

//下面为释放动态内存

for(j=0;j<=i;j++)

free(nickname[j]);

free(nickname);

free(down_i);

free(up_i);

free(time_sum);

return 0;

}

void pai_hang_bang(FILE*fp,char**nickname,double*time_sum,time_t end_time)

{

void deal_rank(char**,double*);//生成排行榜(rank)

int j;

system(“cls”);//清除当前屏幕

deal_rank(nickname,time_sum);

puts(“已将游戏结果将保存在d:/游戏排行榜.txt\n”);

printf(“本轮排行榜为:\n\n保存时间:%s\n\n”,ctime(&end_time));

puts(“时间格式:星期,月,日,小时:分:秒,年\n”);

puts(“排名 成绩 范围 昵称 “);

fprintf(fp,”\n&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&\n”);

fprintf(fp,”\n本轮排行榜为:\n保存时间:%s”,ctime(&end_time));

fputs(“时间格式:星期,月,日,小时:分:秒,年\n”,fp);

for(j=0;j<=i;j++)

{

printf(“\n%-2d %.0LfS %d~%d %s \n”,j+1,time_sum[j],down_i[j],up_i[j],nickname[j]);

fputs(“*******************************************************************”,fp);

fprintf(fp,”\n排名:%-2d”,j+1);

fprintf(fp,”\n成绩:%.0LfS”,time_sum[j]);

fprintf(fp,”\n范围:%d~%d”,down_i[j],up_i[j]);

fprintf(fp,”\n昵称:%s\n”,nickname[j]);

}

}

void deal_rank(char**nickname,double*time_sum)//插入排序法

{

double t_time;

int t_up,t_down;

char t_name[555];

int dai_cha,bi_jiao,hou_yi;//待插,比较,后移

if(time_sum[0]>time_sum[1])

{

t_time=time_sum[0],time_sum[0]=time_sum[1],time_sum[1]=t_time;

}

for(dai_cha=2;dai_cha<=i;dai_cha++)

for(bi_jiao=0;bi_jiao if(time_sum[dai_cha] {

t_time=time_sum[dai_cha];

t_down=down_i[dai_cha];

t_up=up_i[dai_cha];

strcpy(t_name,nickname[dai_cha]);

for(hou_yi=dai_cha;hou_yi>bi_jiao;hou_yi–)

{

time_sum[hou_yi]=time_sum[hou_yi-1];

down_i[hou_yi]=down_i[hou_yi-1];

up_i[hou_yi]=up_i[hou_yi-1];

strcpy(nickname[hou_yi],nickname[hou_yi-1]);

}

time_sum[bi_jiao]=t_time;

down_i[bi_jiao]=t_down;

up_i[bi_jiao]=t_up;

strcpy(nickname[bi_jiao],t_name);

}

}

C语言小游戏

贪吃蛇的源代码

#include#include #include #include typedef struct snake { int a; int b; struct snake *u; struct snake *n; }snake,*snake1; typedef struct food { int a; int b; }food; void main() { char c,c0 = ‘d’; int i,j,k,n=1,t,at; snake p,q; snake *dd,*dd0,*dd1,*dd2; food f; srand(time(NULL)); p.u = NULL; p.n = &q; p.a = 5;p.b = 6;q.a = 5;q.b = 5; q.u = &p;q.n = NULL; dd=dd2= &q; f.a=(rand()%15+1); f.b=(rand()%15+1); while(1) { srand(time(NULL)); system(“cls”); for(i = 0;i < 17;i ++) { for(j = 0; j < 17;j++) { if(i == 0 ) printf("▁"); else if(i == 16) printf("▔"); else if(j == 0) printf("▕"); else if(j == 16) printf("▏"); else if(i == p.a && j == p.b) printf("■"); else if(i == f.a && j == f.b) printf("★"); else { t = 0; dd = dd2; for(k = 0; k < n ;k++) { if(i == dd->a && j == dd->b) { printf(“□”); t = 1; break; } dd = dd->u; } if(t == 0) printf(” “); } }printf(“\n”); } at = 0; dd =dd2; for(i=0;i { if(p.a == dd->a && p.b == dd->b) { printf(“game over!!\n”); exit(0); } dd = dd->u; } if(p.a == f.a && p.b == f.b) { dd = dd2; at =1; f.a = (rand()%15+1); f.b = (rand()%15+1); for(i=0;i { if(f.a == dd->a && f.b == dd->b) { f.a = dd2->a; f.b = dd2->b; break; } } n++; } if(kbhit()) { c = getch(); dd = dd2; if(c == ‘w’ && c0 != ‘s’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } if(p.a == 1) p.a = 15; else p.a = (p.a-1)%15; } else if(c == ‘s’ && c0 != ‘w’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } p.a = (p.a%15)+1; } else if(c == ‘a’ && c0 != ‘d’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } if(p.b == 1) p.b = 15; else p.b = (p.b-1)%15; } else if(c == ‘d’ && c0 != ‘a’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } p.b = (p.b%15)+1; } else { goto qq; } c0 = c; } else { qq: if(c0 == ‘w’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } if(p.a == 1) p.a = 15; else p.a=(p.a-1)%15; } else if(c0 == ‘s’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } p.a=(p.a%15)+1; } else if(c0 == ‘a’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } if(p.b == 1) p.b = 15; else p.b=(p.b-1)%15; } else if(c0 == ‘d’) { if(at == 1) { dd0 =(snake1)malloc(sizeof(snake)); dd0->a = dd2->a;dd0->b = dd2->b; dd0->n = NULL;dd0->u = dd2; dd2=dd0; } dd = dd2; for(i = 0; i { dd1 = dd->u; dd->b = dd1->b; dd->a = dd1->a; dd = dd->u; } p.b=(p.b%15)+1; } } fflush(stdin); dd = &q; _sleep(0); } }