Tenth Week Technical Blog
Data
Learning of Binary Tree traversal
242 Chen Kunxin Tenth week. Cpp:defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
typedef char Datetype;
typedef struct node{
Datetype data;
struct Node *lchild,*rchild;
}*bitree;
void preorder (Bitree root)
{
if (root!=null)
{
printf ("%c", root->data);
Preorder (Root->lchild);
Preorder (Root->rchild);
}
}
void Inorder (Bitree root)
{
if (root!=null)
{
Inorder (Root->lchild);
printf ("%c", root->data);
Inorder (Root->rchild);
}
}
void Postorder (Bitree root)
{
if (root!=null)
{
Postorder (Root->lchild);
Postorder (Root->rchild);
printf ("%c", root->data);
}
}
int main (int argc,char* argv[])
{
printf ("242 Chen Kunxin binary tree traversal \ n");
Bitree T[8];
int i;
for (i=1;i<=7;i++)
{
t[i]= (bitree) malloc (sizeof (*t[0));
T[i]->data= ' A ' +i-1;
t[i]->lchild=null;
t[i]->rchild=null;
}
t[1]->lchild=t[2];t[1]->rchild=t[3];
t[2]->lchild=t[4];//t[2]->rchild=t[5];
t[3]->lchild=t[5];t[3]->rchild=t[6];
t[4]->rchild=t[7];
printf ("Pre-order Traversal");
Preorder (t[1]);
printf ("\ n");
printf ("Middle sequence traversal");
Preorder (t[1]);
printf ("\ n");
printf ("post-post traversal");
Preorder (t[1]);
printf ("\ n");
return 0;
}
References to parent-child nodes
242 Chen Kunxin Tenth week _2.cpp:defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#define MAX 100
typedef char DataType;
typedef struct trees{
DataType Datas[max];
int n;
}trees;
#define NONODE 0
void Getchildparent (Trees *t,datatype x) {
int i;
for (i=1;i<=t->n;i++) {
if (t->datas[i]==x)
Break
}
Int (i>t->n) {
printf ("Without this node \ n"); return;
}
if (i==1) {
printf ("This node%c is the parent node,", x);
}
else printf ("The parent node of this node%c is%c,", X,T->DATAS[I/2]);
if (2*i<=t->n) {
if (t->datas[i*2]! Nonode)
printf ("Left child node is%c,",t->datas[i*2];
else printf ("No left node,");
}
else printf ("No left node,");
if (2*i+1<=t->n) {
if (T->datas[i*2+1]!=nonode)
printf ("Right child node is%c", t->datas[i*2+1]);
else printf ("No Right Node");
}
else printf ("No Right Node");
printf ("\ n");
}
int mai (int argc,char* argv[])
{
Trees;
t.n=13;
T.datas[4]=nonode;t.datas[7]=nonode;
T.datas[8]=nonode;t.datas[9]=nonode;
T.datas[11]=nonode;t.datas[12]=nonode;
t.datas[1]= ' A '; t.datas[2]= ' B ';
t.datas[3]= ' C '; t.datas[5]= ' D ';
t.datas[6]= ' F '; t.datas[10]= ' E '; t.datas[13]= ' G ';
Char c[20];
while (true) {
printf ("Please enter node data:");
scanf ("%s", c);
if (c[0]== ' 0 ') break;
}
return 0;
}
Web Technology
Keyboard keys to change background color
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> keyboard keys to change background color </title>
<body onkeypress= "A ()" >
<script language= "JavaScript" >
function A ()
{
var N=window.event.keycode
Switch (n)
{
Case 97:
Document.bgcolor= "Gray";
Case 119:
Document.bgcolor= "Yellow";
}
}
</script>
</body>
mouse button to change background color
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> mouse button to change background color </title>
<body>
<script language= "JavaScript" >
var color=new Array ("Red", "yellow", "blue");
var n=-1;
function MouseDown () {
Document.bgcolor= "Red";
}
function MouseUp () {
Document.bgcolor= "Blue";
}
</script>
<input type= "button" name= "Change" value= "changing background color" onmousedown= "MouseDown ()" onmouseup= "MouseUp ()"/>
</body>
Show where the mouse is moving
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> shows the location of the mouse movement </title>
<body>
<script language= "JavaScript" >
var x=0,y=0;
function Mouseplace ()
{
X=window.event.x;
Y=window.event.y;
window.status= "X:" +x+ "" + "Y:" +y+ "";
}
Document.onmousemove=mouseplace;
</script>
</body>
Week number |
Professional Learning Goals |
Professional Learning Time |
New Code Volume |
Blog post Volume |
Learning in the Humanities |
Knowledge and Skills Summary |
Tenth Week |
Data structure binary tree traversal and parent-child node, Web technology mouse keyboard event programming |
5 |
400h |
2 |
No |
The binary tree is understandable but not well represented in the code, and Web technology event programming is well-mastered |
Tenth Week Technical Blog