没有说明白,叫人怎么给你做。
如果两个人玩的话,很简单。
做个图形界面陆昌然后设置上下左右键盘,然后记录分数的函数就可以了。
如果机器玩的话(察悉吵这种情况算是演示了,不可能有)
最难办的是 人和机器玩了
这是后要 涉及到算法分析和数据结构的内容了。
当然 这是的情况是 机器一定赢过人了败侍。(算法)
就这么做啊 不知道你要的是哪一种。
#include<stdio.h>耐芹#include<graphics.h>衫饥
int main()
{
int gdriver,gmode,i
gdriver=DETECT
initgraph(&gdriver,&gmode," ")
setbkcolor(BLUE)
cleardevice()
setcolor(WHITE)
line(20,20,20,180)
line(20,20,280,20)
setcolor(8)
line(20,180,280,180)
line(280,180,280,20)
setcolor(7)
line(21,21,21,179)
line(21,21,279,21)
line(21,179,279,179)
line(279,179,279,21)
setfillstyle(1,7)
floodfill(30,50,7)
setcolor(8)
line(30,30,270,30)
line(30,30,30,170)
setcolor(15)
line(30,170,270,170)
line(270,170,270,30)
setcolor(7)
line(31,31,31,169)
line(31,31,269,169)
line(31,169,269,169)
line(269,169,269,31)
floodfill(25,25,7)
setcolor(13)
settextstyle(1,0,2)
outtextxy(115,85,"window"昌塌毕)
getch()
closegraph()
return 0
}
#include<reg52.h>sbit LCD_RS = P2^0
sbit LCD_RW = P2^1
sbit LCD_E_ = P2^2
sbit KEY1 = P2^3
void Delay_ms(unsigned char time)
{
unsigned char 蠢租i
while(time--)
{
带历兆 for(i=0i<125i++)
}
}
void LCD1602_WriteByte(unsigned char value,bit dataTypedef)
{
LCD_RS = dataTypedef
LCD_RW = 0
P0 = value
LCD_E_ = 1
Delay_ms(5)
LCD_E_ = 0
}
void LCD1602_Init()
{
LCD1602_WriteByte(0x38,0)
Delay_ms(10)
LCD1602_WriteByte(0x01,0)
Delay_ms(10) 烂则
LCD1602_WriteByte(0x06,0)
Delay_ms(10)
LCD1602_WriteByte(0x0c,0)
Delay_ms(10)
}
bit Pause
void KEY_Testing()
{
static bit sw
static unsigned char qd
KEY1 = 1
if(!KEY1)
{
if(!sw)qd++
if(qd>10)
{
qd = 0
sw = 1
if(!KEY1)Pause=~Pause
}
}
else
sw = qd = 0
}
unsigned char CountNumber
void main()
{
LCD1602_Init()
TMOD = 0x01
TR0 = 1
ET0 = 1
EA = 1
while(1)
{
LCD1602_WriteByte(0x85,0)
LCD1602_WriteByte((CountNumber/100)+48,1)
LCD1602_WriteByte((CountNumber/10%10)+48,1)
LCD1602_WriteByte((CountNumber%10)+48,1)
}
}
void Timer0_Routine()interrupt 1
{
static unsigned int count
TH0 = 0xfc//12MHZ
TL0 = 0x18
KEY_Testing()
if(!Pause)
{
count++
if(count>=1000)
{
count=0
}
}
}
///如有问题,可再咨询
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)