Learning Week Summary

Source: Internet
Author: User

Time is not noticed. But this week's HTML study added last week's time and level. Data structure, learning the concept of the tree and the storage principle, the code is on the basis of the teacher to change. This week read the prose written by Ben Bi Shumin, one of which is that tourism is our modesty, empathy, go out, to let me find out how big the world, otherwise the old house in a place may let my vision narrow, bosom oblique. Tourism is with a kind of unknown charm, arousing people's tireless yearning.

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Fun Games </title>

<script type= "Text/javascript" >
var currimg1=-1;
var lastimg1=-1;
var count=0;
var n;
var isused=new Array ();
var row=3;
var col=4;
Clock variables
var mytime=60;
var minute;
var secound;
var str1;
var count;
var myinter;

var myarray=new Array (34);


function Mysort ()
{
Return Math.random () >.5;
}

function init (row, col)
{
n= (Row*col)/2;
For (Var k=0;k< (n*2); k++)
{
Isused[k]=false;
}
for (Var k=0;k<n;k++)
{
Myarray[k]= (Math.Round (Math.random () *9) +1);
MYARRAY[K+N]=MYARRAY[K];
}
Myarray.sort (Mysort);


var str= ' <table name= "MyT" border= "1" width= "" height= "bgcolor=" #FFFFFF "bordercolor=" #9F9 "border=" 1 " cellspacing= "1" cellpadding= "1" > ";
for (Var i=1;i<=row;i++)
{
str+= "<tr>";
for (Var j=0;j<col;j++)
{
str+= "<td onclick= ' Judge (" + ((i-1) *col +j) + "); ' > "
str + = "str+= "</td>";
}
str+= "</tr>";
}
str+= "</table>"
document.getElementById ("Mt"). Innerhtml=str;

}
function CreateTable ()
{
Init (Row,col);
row++;
col++;
Myinter=setinterval (settime,1000);
}
Function Judge (temp)
{
if (Isused[temp]) return;
Isused[temp]=true;
LASTIMG1=CURRIMG1;
Currimg1=temp;



var Currimg=document.getelementbyid ("Img_" +temp);
Currimg.src= "Photo/image" +myarray[temp]+ ". jpg";
Alert (myarray[temp]);
if (currimg1>=0 &&lastimg1>=0)
{

if (MYARRAY[CURRIMG1]==MYARRAY[LASTIMG1])
{
count++;
Currimg1=lastimg1=-1;
if (count>=n)
{
Clearinterval (Myinter);
Mytime=mytime+ ((n*2) +40);
Alert ("Congratulations to the next level, click Confirm to continue");
CreateTable ();
count=0;


}
}
Else
{

var Lastimg=document.getelementbyid ("Img_" +LASTIMG1);
Lastimg.src= "Photo/image0.jpg";
Isused[lastimg1]=false;
}

}
}

function settime ()//Timer
{

Minute=math.floor (MYTIME/60);
secoud=mytime%60;
Str1=string (minute+100). substr (+) + ":" +string (secoud+100). substr;
document.getElementById ("Mt2"). Innerhtml=str1;
mytime--;
if (mytime<0)
{
Clearinterval (Myinter);
}

}

</script>
<style type= "Text/css" >
<!--
Body {
Background-image:url (photo/bg1.jpg);
Background-repeat:repeat;
}
body,td,th {
Color: #06F;
font-size:24px;
Font-weight:bold;
}
-
</style>

<body><br>
<br><br>
<br><br><br>
<br>
<div id= "MT4" align= "center" ></div>
<div id= "mt2" align= "Center" >
<p> Time </p>
</div>
<table width= "100%" border= "0" align= "center" >
<tr>
<TD align= "center" ><br>
<div id= "MT" > </div>
<p>

<input name= "Buttons" type= "button" Id= "B1" onclick= "CreateTable ();" value= "Start"/>
</p></td>
</tr>
</table>
<br>
<p>&nbsp;</p>
</body>

C language

#include "stdio.h"

#define MAX2 20

typedef char DataType;

typedef struct CTYPENODE_CHILD{/* table node for single-linked list * /

int child;

struct Ctypenode_child *next;

}cptr;

typedef struct ctypenode_head{

DataType data;

Cptr *firstchild; /* head node for single linked list * /

}ctypenode;

typedef struct{

Ctypenode NODES[MAX2];

number of nodes of the int n;/* tree * /

}ctypetree;

void Linktree (Ctypetree t,datatype x)// based on node x, outputs its parent and child nodes.

{

Cptr *pc;

int i,posi,parent;

for (i=0;i<t.n;i++) {

if (t.nodes[i].data==x) {//Determine if this node

posi=i;//Yes, the location where this node is saved

The following code looks for the child nodes.

pc=t.nodes[i].firstchild;//node pointer, NULL to indicate no sub-node.

if (pc!=null) {//whether there are child nodes

printf ("Sub-node of this node %c is ", x);// loop out its sub-nodes

while (Pc!=null) {

printf ("%c", t.nodes[pc->child].data);

pc=pc->next;

}

}

else printf (" this node %c has no sub-nodes ", x);

printf ("\ n");

break;// Find this node, no need to find it, exit the loop

}

}

if (I==T.N) {// loop to last no, yes indicates no found, no this node

printf (" Without this node %c\n\n", x); return;

}

The following code looks for the parent node.

if (posi==0)// whether the root node

printf (" This node %c is the root node \ n", x);// Yes, the output root node

else {

Parent=-1;

for (i=0;i<t.n;i++) {

Pc=t.nodes[i].firstchild; Loop through each node.

while (Pc!=null) {

if (Pc->child==posi) {//its sub-node number is the same as the current node number.

Parent=i;goto Lab; Yes, find the parent node and exit

}

The pc=pc->next;//pointer moves to the next sub-node and continues to look for it.

}

}

Lab:if (parent==-1) printf ("Data input error \ n");//If the parent node is not found, the data input is wrong

Else printf ("Parent node of this node%c is%c\n", x,t.nodes[parent].data);//Output parent node

}

printf ("\ n");

}

int main (int argc, char* argv[])

{printf ("TheChild brother node of the 133 tree indicates \ n");

Ctypetree T;

Cptr cps[9];;

t.n=9;

int i;

for (i=0;i<t.n;i++) {

T.nodes[i].data= ' A ' +i;

T.nodes[i].firstchild=null;

Cps[i].next=null;

Cps[i].child=i;

}

t.nodes[0].firstchild=&cps[1]; cps[1].next=&cps[2]; cps[2].next=&cps[3];

t.nodes[1].firstchild=&cps[4];

t.nodes[3].firstchild=&cps[5];cps[5].next=&cps[6]; cps[6].next=&cps[7];

t.nodes[6].firstchild=&cps[8];

Char c[20];

while (true) {

printf (" Please enter node data :");

scanf ("%s", c);

if (c[0]== ' 0 ') break;

if (c== ' \ n ') continue;

Linktree (T,c[0]);

}

return 0;

}

Learning Week Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.