第九周
数据结构:
LNode*creatList(void)
{
LNode*head;
LNode*s;
LNode*p;
int c;
head=(LNode*)malloc(sizeof(LNod));
p=head;
p->next=NULL;
Printf("输入链表结点数据,当输入值<=0时建表完成,该值不接入链表\n");
scanf("%d",&c);
while(c>0)
{
s=(LNode*)malloc(sizeof(LNode));
s->data=c;
s->next=p->next;
p->next=s;
scanf("%d",&c);
}
Printf("creatList 函数执行,创建链表成功\n");
return head;
}
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>水果消消乐</title>
<script type="text/javascript" >
var myArray=new Array();
var lastmyarr=-1;
var currmyarr=-1;
var n;//方框总数
var count=0;//单回合计分
var prive=new Array();
var time=0;
var row=3;//起点行列
var col=4;
var sum=0;//总分累加变量
var TimeLimit=20;
function Timepiece()//计时器
{
document.getElementById("countT").value=time;
time=time+1;
setTimeout("Timepiece()",1000);
}
function put()
{
n=(col*row)/2;
for(var i=0 ; i<(2*n) ; i++)
{
prive[i]=false;
}
for(var k=0;k<n;k++)
{
myArray[k]=( Math.ceil( Math.random()*18 ));
myArray[k+n]=myArray[k];
}
myArray.sort(mySort);
var str="<table border='3'>";//表格生成
for(var i=0; i<row ;i++)
{
str+="<tr>";
for(var j=0 ; j<col; j++)
{
str+="<td onClick='judge("+(col*i+j)+")' align='center' >";
str+="<img id='img_"+(col*i+j)+"' src='image/image0.jpg' width='120px'>";
str+="</td>";
}
str+="</tr>";
}
str+="</table>";
str+="总分:<input type='text' id='score' value='"+(sum)+"'>"
str+="花费时间:<input style='color:red;width:50px;background:white;' type='text' id='countT' value=''>"
document.getElementById("mt").innerHTML=str;
}
function mySort()
{
return Math.random()>.5;
}
function judge(e)
{
if(prive[e]) return;
prive[e]=true;
lastmyarr=currmyarr;
currmyarr=e;
var temp=document.getElementById("img_"+e);
temp.src="image/image"+myArray[e]+".jpg";
if(myArray[lastmyarr]==myArray[currmyarr])
{
lastmyarr=currmyarr=-1;
count++;
if(time==TimeLimit)
{
alert("游戏结束,你的分数为"+sum);
return;
}
if(count>=n)
{
alert("游戏通关,下一关开始");
col++;
row++;
time=0;//游戏时间清零
sum+=(count*10);
count=0;
TimeLimit=TimeLimit+10;
put();
}
}
else
{
var temp=document.getElementById("img_"+lastmyarr);
temp.src="image/image0.jpg";
prive[lastmyarr]=false;
}
}
</script>
</head>
<body id="mt" background="background.jpg">
<input type="button" value="Start" onclick="put();Timepiece();" >
</body>
</html>