巴克纳c语⾔⼩游戏代码300⾏,谁有50⾏和300⾏左右⼜简单的程序,
急需
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
/*拼图(数字型)通过1,2,3,4控制空⽩位置移动,使1--8顺序排列*/
/*有很多可改进之处,你⾃⼰再改改吧*/
#include
#include
#include
void screen(short *);/*屏幕显⽰*/
int judge(short *); /*是否已完成的判断*/
int flag=0;/*是否已完成标志*/
main()
{
春秋诸侯国int i,j;
char ch;
short arror[9];
日月潭课件
int graphdriver=DETECT,graphmode;
initgraph(&graphdriver,&graphmode,"D:\\TurboC");/*改为⾃⼰的图形驱动所在位置*/
cleardevice();
tactivepage(0);
tvisualpage(0);
randomize();
for(i=0;i<=8;i++)
{
arror[i]=random(9);
for(j=0;j
if(arror[j]==arror[i])
{广西毕业生就业网
玩球i=i-1;
break;
}
}
screen(arror);
while(!flag)
{
i=0;
while(arror[i])i++;
ch=getch();
switch(ch)
{
ca '1':if(i%3!=0){arror[i]=arror[i-1];arror[i-1]=0;}screen(arror);break;
ca '2':if((i+1)%3!=0){arror[i]=arror[i+1];arror[i+1]=0;}screen(arror);break;
ca '3':if(i/3!=0){arror[i]=arror[i-3];arror[i-3]=0;}screen(arror);break;
ca '4':if(i/3!=2){arror[i]=arror[i+3];arror[i+3]=0;}screen(arror);break;
default:flag=1;break;/*任意键退出*/
中国铁路的发展
}
}
}
int judge(short arror[9])
{
int i;
紫甘蓝炒肉
for(i=0;i<=8;i++)if(arror[i]!=i-1)return 0;
return 1;
}
void screen(short arror[9])/*屏幕显⽰*/
{
int i;
cleardevice();
ttextstyle(TRIPLEX_FONT, HORIZ_DIR, 6);
turcharsize(1, 1, 1, 1);
tfillstyle(1,4);
outtextxy(10,10,"1:left; 2:right; 3:up; 4:down; other:quit");
散步英语怎么说ttextstyle(TRIPLEX_FONT, HORIZ_DIR, 6);
turcharsize(2, 1, 1, 1);
tfillstyle(1,4);
rectangle(100,100,150,150);rectangle(150,100,200,150);rectangle(200,100,250,150); rectangle(100,150,150,200);rectangle(150,150,200,200);rectangle(200,150,250,200);
rectangle(100,200,150,250);rectangle(150,200,200,250);rectangle(200,200,250,250); for(i=0;i<=8;i++)
{
switch(arror[i])
{
ca 0:floodfill(100+i%3*50+15,100+i/3*50+15,0);break;
ca 1:outtextxy(100+i%3*50+10,100+i/3*50+10,"1");break;
ca 2:outtextxy(100+i%3*50+10,100+i/3*50+10,"2");break;
ca 3:outtextxy(100+i%3*50+10,100+i/3*50+10,"3");break;
ca 4:outtextxy(100+i%3*50+10,100+i/3*50+10,"4");break;
ca 5:outtextxy(100+i%3*50+10,100+i/3*50+10,"5");break;
ca 6:outtextxy(100+i%3*50+10,100+i/3*50+10,"6");break;
ca 7:outtextxy(100+i%3*50+10,100+i/3*50+10,"7");break;
ca 8:outtextxy(100+i%3*50+10,100+i/3*50+10,"8");break;
}
}
return;
}