第十周技术博客

数据结构

二叉树遍历的学习

// 242陈坤鑫第十周.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 陈坤鑫 二叉树遍历\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("前序遍历");

PreOrder(t[1]);

printf("\n");

printf("中序遍历");

PreOrder(t[1]);

printf("\n");

printf("后序遍历");

PreOrder(t[1]);

printf("\n");

return 0;

}

父子结点的引用

// 242陈坤鑫第十周_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("无此结点\n\n");return;

}

if(i==1){

printf("此结点%c为父结点,",x);

}

else printf("此结点%c的父结点为%c,",x,t->datas[i/2]);

if(2*i<=t->n){

if(t->datas[i*2]!NoNode)

printf("左孩子结点为%c,",t->datas[i*2];

else printf("无左结点,");

}

else printf("无左结点,");

if(2*i+1<=t->n){

if(t->datas[i*2+1]!=NoNode)

printf("右孩子结点为%c",t->datas[i*2+1]);

else printf("无右结点");

}

else printf("无右结点");

printf("\n\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("请输入结点数据:");

scanf("%s",c);

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

}

return 0;

}

Web技术

键盘按键改变背景色

<!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>

</head>

<body onkeypress="a()">

<script language="javascript">

function a()

{

var n=window.event.keyCode

switch(n)

{

case 97:

document.bgColor="gray";break;

case 119:

document.bgColor="yellow";break;

}

}

</script>

</body>

</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>

</head>

<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="变化背景颜色" onmousedown="mousedown()" onmouseup="mouseup()"/>

</body>

</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>

</head>

<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>

</html>


周数


专业学习目标


专业学习时间


新增代码量


博客发表量


人文方面的学习


知识技能总结


第十周


数据结构二叉树遍历和父子结点,Web技术鼠标键盘事件编程


5


400h


2



二叉树能够理解但在代码上无法很好的表现出来,web技术事件编程掌握良好

时间: 2024-08-01 22:46:28

第十周技术博客的相关文章

第九周技术博客

链式队列 // 242陈坤鑫第九周.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "stdio.h" #include "stdlib.h" typedef int DataType; typedef struct Space { DataType data; Space* next; }Space; typed

第八周技术博客

简单的贪吃蛇 (function() { var canvas = document.getElementById("canvas"); var ctx = canvas.getContext('2d'); ctx.fillStyle = "#0f0"; ctx.strokeStyle = "#f00"; //按下键盘的响应参数 var keyList = { 37: [-1,0], 38: [0,-1], 39: [1,0], 40: [0,1

第五周技术博客

l  周筠老师: u  过早退出是一切失败的根源:http://zhuanlan.zhihu.com/#/yeka52/20035192 u  来吧,IT小小鸟:http://zhuanlan.zhihu.com/#/yeka52/19927299 请同学们延伸阅读,了解<我是IT小小鸟>书中的主人公目前的发展情况.心路历程.以及周老师,为IT初学者提供的专业学习链接与问答. 关注他们,了解他们在说什么!如何成长和诠释IT人. l  金旭亮老师:https://www.zhihu.com/pe

第六周技术博客

<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>sessionStorage与localStorage区别</title> </head> <body> <h1>计数器</h1> <p class="msg" id="msg_1"> <

第八周 技术博客发表

#include "stdafx.h" #include "stdio.h"#include "stdlib.h" typedef int DataType; typedef struct Space{ DataType data; Space* next;}Space; typedef struct Queue{ Space* base; Space* top; int length; }Queue; Queue* initQ(){ Queue

第十周 学习博客2

bootstrap 栅格系统用法:随着屏幕尺寸的扩大,系统会自动分为最多12列. 可分为:xs最小屏幕,sm小屏幕,md中等屏幕,lg大屏幕 如图所示: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div

第十周 学习博客3

Bootstrap 中在<button> 类中定义属性,可以改变按钮的颜色: <button type="button" class="btn btn-default">Default</button> <button type="button" class="btn btn-primary">Primary</button> <button type=&quo

第十周 学习博客

学习了JavaScript中脚本化图片转换的方式,有三种可以转变的方式: 1.在<img> 标签中添加onmouseover,onmouseout属性: <img src="images/1.jpg" onmouseover="this.src='images/2.jpg'" onmouseout="this.src='images/3.jpg'"> 在鼠标移动前网页显示为: 鼠标移动后页面显示为: 2.预提取使用的翻转图

价值博客们,技术博客

www.raychase.net http://mindhacks.cn 程序员博客墙blogwall.us http://www.cppblog.com/vczh MacTalk-池建强的随想录 Fenng DBA Notes | 闲思录robbin的自言自语风雪之隅-Laruence的博客 blog.vgod.tw 张琮翔的Blog:愛好電腦.科技.程式設計,目前在MIT電腦科學與人工智慧實驗室就讀博士班,尋找人機互動與程式設計交會的創新火花. MIT CSAIL的PhD,现在毕业开始创业了