经过了一周的学习,我们在html以及C语言方面又有的新的知识点的学习。

html

自习表格,函数等

C语言

哈弗曼编码

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>

<form name="form1" method="post" action="">

<table width="221" border="1"  cellpadding="0" cellspacing="0">

<tr>

<td height="30" colspan="2"> 用户登录</td>

</tr>

<tr>

<td width="59" height="30"> 用户名</td>

<td width="162" ><input name="user" type="text" id="user" /></td>

</tr>

<tr>

<td height="30" >密   码:</td>

<td> <input name="pwd" type="text" id="pwd"/></td>

</tr>

<tr>

<td height="30" colspan="2" align="center"><input name="Button" type="button" class="btn_grey" value="登录" onclick="check()" />

<input name="submint2" type="reset" class="btn_grey" value="重置" />

</td>

</tr>

</table>

</form>

<script type="text/javascript">

/*

P243 14-3

P246 14-6

P251 14-8 界面实现建议用表单的方式。

*/

var num1=120,num2=25;

document.write("120+25="+(num1+num2)+"<br >");

document.write("120-25="+(num1-num2)+"<br >");

document.write("120*25="+(num1*num2)+"<br >");

document.write("120/25="+(num1/num2)+"<br >");

document.write("(120++)"+(num1++)+"<br >");

document.write("(++120)="+(++num1)+"<br >");

var a=3;

var b="name";

var c=null;

alert("a的类型为:"+(typeof a)+"\nb的类型为:"+(typeof b)+"\nc的类型为:"+(typeof c));

function check()

{

var name=form1.user.value;

var pwd=form1.pwd.value;

if((name=="")||(name=null))

{

alert("请输入用户名");

form1.user.focus();

return;

}

else if((pwd=="")||(pwd=null))

{

alert("请输入密码");

form1.pwd.focus();

return;

}

else

{

form1.submit();

}

}

</script>

<body>

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

<script type="text/javascript">

/*

P258  14-13  学习函数  countdown ,

1 明白参数传递实现,掌握 "id"属性作为实参的用法。

2 学会Date 的使用

3 尝试将countdown改写成switch ---case 的条件判断

4 页面实现改成成表单格式。

*/

function countdown(title,Intime,divId)

{

var online=new Date(Intime);

var now=new Date();

var leave =online.getTime()-now.getTime();

var day=Math.floor(leave/(1000*60*60*24))+1;

if(day>=0)

{

switch(day)

{

case 0:divId.innerHTML="<b>就是今天"+title+"呀!</b>";break;

case 1:divId.innerHTML="<b>-明天就是"+title+"啦!</b>";break;

default :divId.innerHTML="<b>-据"+title+"还有"+day+"天!</b>";break;

}

}

else

{

divId.innerHTML="<b>-哎呀"+title+"已经过了!</b>";

}

}

</script>

<body>

<table width="350" height="450" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td valign="bottom"><table width="346" height="418" border="0" cellpadding="0" cellspacing="0">

<tr>

<td width="76"> </td>

<td width="270">

<div id="countDown">

<b>-</b></div>

<script type="text/javascript">

countdown("2016年母亲节","5/8/2016",countDown);

</script>

</td>

</tr>

</table></td>

</tr>

</table>

</body>

</html>

C语言案例:

// 303.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"

#include <stdio.h>

#include <string.h>

typedef char DataType;

struct element  //结点定义

{

DataType data;

float weight;//此字符的权值

int parent,lchild, rchild;//父结点,左孩子,右孩子存放位置

};

#define MAXLEAF 6  //最大叶子结点数目,待编码的字符数

#define MAXNODE MAXLEAF*2-1   //最大结点数

struct Huffmancode{

DataType ch;//存放字符

char bits[MAXLEAF];//存放字符的哈夫曼编码

};

Huffmancode hcode[MAXLEAF];

//element ht[ MAXNODE];

//此函数为选取两个最小的权值结点的位置 分别分别存放在pn[0],pn[1]

void Select (element *pt,int n, int *pn){

int i,iposi=0;

float tmp;

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

if(pt[i].parent==-1)

{

tmp=pt[i].weight;pn[0]=i;

iposi=i;

break;

}

}

for(i=iposi;i<n;i++){

if(tmp>pt[i].weight && pt[i].parent==-1){

pn[0]=i; tmp=pt[i].weight;

}

}

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

if(pt[i].parent==-1 && i!=pn[0])

{

tmp=pt[i].weight;pn[1]=i;

iposi=i;

break;

}

}

for(i=iposi;i<n;i++){

if(tmp>pt[i].weight && pt[i].parent==-1 && i!=pn[0]){

pn[1]=i; tmp=pt[i].weight;

}

}

return;

}

//此函数功能为创建哈夫曼树

void CreateHuffmanTree(element *pt){

int i,k=0;

int pn[2];

for(i=MAXLEAF ;i<MAXNODE;i++){

//选取两个最小的权值结点的位置 分别分别存放在pn[0],pn[1]

Select(pt,MAXLEAF+k,pn);

k++;

pt[pn[0]].parent=pt[pn[1]].parent=i;

pt[i].lchild=pn[0]; pt[i].rchild=pn[1];

pt[i].weight=pt[pn[0]].weight+pt[pn[1]].weight;

}

}

//此函数功能为生成哈夫曼编码

void CreateHuffmanCode(element *pt,int n){

int i,p,j,start;

char cd[MAXNODE];

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

start=n-1;

cd[start]=0;

p=pt[i].parent;

j=i;

//从叶子结点出发,逐层遍历到根结点,逆序求出每个结点的哈夫曼编码

while(p!=-1){//当p为 -1时,表示遍历到根结点

if(pt[p].lchild==j)

cd[--start]='0';//左孩子编码为0

else

cd[--start]='1'; //右孩子编码为1

j=p;

p=pt[p].parent;

}

strcpy(hcode[i].bits,&cd[start]);

}

}

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

{

printf("303 柳晓雅\n");

element ht[MAXNODE];

int i;

for(i=0;i<MAXNODE;i++) {

ht[i].parent=-1;

ht[i].lchild=-1;

ht[i].rchild=-1;

ht[i].data=' ';

ht[i].weight=0;

}

//ht[0].data='A' ;ht[0].weight=2;  hcode[0].ch=ht[0].data;

//ht[1].data='B' ;ht[1].weight=4;  hcode[1].ch=ht[1].data;

//ht[2].data='C' ;ht[2].weight=5;  hcode[2].ch=ht[2].data;

//ht[3].data='D' ;ht[3].weight=3;  hcode[3].ch=ht[3].data;

ht[0].data='A' ;ht[0].weight=28;  hcode[0].ch=ht[0].data;

ht[1].data='B' ;ht[1].weight=13;  hcode[1].ch=ht[1].data;

ht[2].data='C' ;ht[2].weight=30;  hcode[2].ch=ht[2].data;

ht[3].data='D' ;ht[3].weight=10;  hcode[3].ch=ht[3].data;

ht[4].data='E' ;ht[4].weight=12;  hcode[4].ch=ht[4].data;

ht[5].data='F' ;ht[5].weight=7;  hcode[5].ch=ht[5].data;

CreateHuffmanTree(ht);//生成哈夫曼树

CreateHuffmanCode(ht,MAXLEAF);//生成哈夫曼编码

//输出每个字符的编码

float weight=0;

for(i=0;i<MAXLEAF;i++){

weight +=ht[i].weight*strlen(hcode[i].bits);

printf("字符=%c 权值=%f 编码=%s\n",hcode[i].ch, ht[i].weight,hcode[i].bits);

}

printf("weight=%f\n",weight);

return 0;

}

周总结<4>的更多相关文章

  1. 2015 Autodesk 开发者日( DevDays)和 助力开发周火热报名中

    Autodesk 软件(中国)有限公司 ADN 市场部真诚地邀请您参加我们一年一度的 "Autodesk 开发者日"(简称 DevDays),以及第一次随同开发者日举办的" ...

  2. 记一周cdqz训练

    #include <cstdio> using namespace std; int main(){ puts("转载请注明出处:http://www.cnblogs.com/w ...

  3. java第三周学习

    这一周学习的是java数组面向对象 数组中存放的数据的类型:既可以是基本数据类型也可以是引用数据类型. 数组的定义方式: 1 数据类型[] 数组名; 2 数据类型 数组名[]; 数组的初始化: 1.静 ...

  4. java第二周周学习总结

    java运算符和循环 java运算符 一.for 语句 for 语句的基本结构如下所示:for(初始化表达式;判断表达式;递增(递减)表达式){    执行语句;   //一段代码} 初始化表达式:初 ...

  5. my97DatePicker选择年、季度、月、周、日

    My97DatePicker是一款非常灵活好用的日期控件.使用非常简单. 下面总结下使用该日历控件选择年.季度.月.周.日的方法. .选择年 <input id="d1212" ...

  6. 第16周界面设计PSP总结

    计划:需1周完整完成 需求分析:作为一个观众,我希望能够了解每一场的比分结果,随时跟进比赛进程 生成设计文档:暂无 设计复审:暂无与组员进行设计复审 代码规范:Visual Studio2010 具体 ...

  7. 三周,用长轮询实现Chat并迁移到Azure测试

    公司的OA从零开始进行开发,继简单的单点登陆.角色与权限.消息中间件之后,轮到在线即时通信的模块需要我独立去完成.这三周除了逛网店见爱*看动漫接兼职,基本上都花在这上面了.简单地说就是用MVC4基于长 ...

  8. 根据起止日期构建指定查询条件:第N周(yyyy-MM-dd/yyyy-MM-dd)

    项目中有个查询模块中用到查询条件: 年和周. 以往我直接指定是第几周,后来测试反映如果直接选择周的话并不知道所选周代表的年月日,而无法最快查询数据,后更改查询条件如下: 指定一个起始年月,根据起始年月 ...

  9. 第0/24周 SQL Server 性能调优培训引言

    大家好,这是我在博客园写的第一篇博文,之所以要开这个博客,是我对MS SQL技术学习的一个兴趣记录. 作为计算机专业毕业的人,自己对技术的掌握总是觉得很肤浅,博而不专,到现在我才发现自己的兴趣所在,于 ...

  10. 从零开始学Python第一周:Python基础(上)

    Python语法基础(上) 一,Python的变量 (1)创建变量 变量的含义:存储信息的地方 创建变量并赋值 x = 1 print x x = 123 #再次赋值 print x (2)使用变量 ...

随机推荐

  1. 如何使用yii2的缓存依赖特性

    目录 如何使用yii2的缓存依赖特性 概述 页面缓存 缓存依赖 链式依赖 总结 如何使用yii2的缓存依赖特性 概述 缓存是Yii2的强大特性之一,合理使用缓存技术可以有效地减小服务器的访问压力.Yi ...

  2. nginx 开启phpinfo

    在nginx配置文件中加 location / { //如果是资源文件,则不走phpinfo模式 if (!-e $request_filename){ ewrite ^/(.*)$ /index.p ...

  3. python写爬虫时的编码问题解决方案

    在使用Python写爬虫的时候,常常会遇到各种令人抓狂的编码错误问题.下面给出一些简单的解决编码错误问题的思路,希望对大家有所帮助. 首先,打开你要爬取的网站,右击查看源码,查看它指定的编码是什么,如 ...

  4. docker 容器 设置网络代理

    以/bin/bash 形式进入容器: [设置http 及https代理],如下: export http_proxy=http://172.16.0.20:3128 export https_prox ...

  5. ubuntu 和windows 分别在anaconda上安装tensorflow

    windows下 的anaconda安装tensorflow: 在Anaconda Prompt中:conda install tensorflow python=3.5一直下载失败.总结一下原因可能 ...

  6. 安装虚拟机&Linux命令学习

    安装虚拟机&Linux命令学习 基于VirtualBox虚拟机安装Ubuntu 1.下载安装VirtualBox 根据自己电脑(32位操作系统)的实际情况,我在网上找了相应的VirtualBo ...

  7. 20155325 加分作业 实现pwd

    要求 1 学习pwd命令 2 研究pwd实现需要的系统调用(man -k; grep),写出伪代码 3 实现mypwd 4 测试mypwd 准备 思路 问题 1.如何获取当前目录的节点号 Linux ...

  8. Ubuntu配置android环境

    jdk:http://www.oracle.com/technetwork/cn/java/javase/downloads/index.html 安装JDK的步骤:http://jingyan.ba ...

  9. 1. oracle12C的安装

    官方安装文档:https://docs.oracle.com/database/121/LTDQI/toc.htm#BHCCADGD 1.软件准备 oracle12c.zip 安装包 VMware 虚 ...

  10. 【AHOI2013】差异

    题面 题解 $ \because \sum_{1 \leq i < j \leq n} i + j = \frac{n(n-1)(n+1)}2 $ 所以只需求$\sum lcp(i,j)$即可. ...