<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CG的技术博客</title>
	<atom:link href="http://fantaci.org/feed" rel="self" type="application/rss+xml" />
	<link>http://fantaci.org</link>
	<description></description>
	<lastBuildDate>Tue, 20 Jul 2010 01:53:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Coming OIA Project</title>
		<link>http://fantaci.org/archives/671</link>
		<comments>http://fantaci.org/archives/671#comments</comments>
		<pubDate>Tue, 20 Jul 2010 01:53:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[OHS]]></category>
		<category><![CDATA[OIA]]></category>
		<category><![CDATA[个人生活]]></category>

		<guid isPermaLink="false">http://fantaci.org/archives/671</guid>
		<description><![CDATA[OIA的技术培训已经一周，目前进度良好，顺便冒个泡，CG预计将在8月初开始OIA Project，たのしみ！
The Coming OIA Project is a post from fantaci.org and cg45.cn
<p><a href="http://fantaci.org/archives/671">The Coming OIA Project</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>OIA的技术培训已经一周，目前进度良好，顺便冒个泡，CG预计将在8月初开始OIA Project，たのしみ！</p>
<p><a href="http://fantaci.org/archives/671">The Coming OIA Project</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/671/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kivi有话说</title>
		<link>http://fantaci.org/archives/667</link>
		<comments>http://fantaci.org/archives/667#comments</comments>
		<pubDate>Fri, 02 Jul 2010 09:10:36 +0000</pubDate>
		<dc:creator>kivi</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://fantaci.org/archives/667</guid>
		<description><![CDATA[学了两个星期的JDE,还是不太清楚这是个嘛东西.不过也还好,还能接受.
这个星期又要结束了,每天早上八点十分出门,走15分钟去等班车,班车是八点半到,每次那个偶像级的人物都背着他的大包坐在草地上.据说他以前是给人家看大门的,然后自学计算机的,很强悍.
我们现在待在一个大办公室里,除了我们三个新来的,其他都是在做项目.都是偶像级别的人物,每天都听到用不同的语言进行电话交流,太fashion了&#8230;&#8230;但是据我观察,也有打酱油的&#8230;&#8230;
晚上回家都要做饭,一开始都是其他两个人做,我切菜,但是后来我自己也开始做了,我觉得做的还不错,上次做了一个fashion的可乐鸡翅,大家感觉很不错,呵呵&#8230;&#8230;
就中午吃饭而言,我得出一个结论,经常自带午饭的就是结婚的,偶尔自带午饭的就是有对象的,但是不是所有有对象的男士都自带午饭,也有像我们老师这样,只有自己一个人吃饭的,他说他很孤独,每天都一个人去吃午饭,因为他对象不给他做饭&#8230;&#8230;嘿嘿
最近天气开始热了,夏天要开始了,这么热的天怎么过呢&#8230;&#8230;This is a question&#8230;&#8230;
Kivi有话说 is a post from fantaci.org and cg45.cn
<p><a href="http://fantaci.org/archives/667">Kivi有话说</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>学了两个星期的JDE,还是不太清楚这是个嘛东西.不过也还好,还能接受.<br />
这个星期又要结束了,每天早上八点十分出门,走15分钟去等班车,班车是八点半到,每次那个偶像级的人物都背着他的大包坐在草地上.据说他以前是给人家看大门的,然后自学计算机的,很强悍.<br />
我们现在待在一个大办公室里,除了我们三个新来的,其他都是在做项目.都是偶像级别的人物,每天都听到用不同的语言进行电话交流,太fashion了&#8230;&#8230;但是据我观察,也有打酱油的&#8230;&#8230;<br />
晚上回家都要做饭,一开始都是其他两个人做,我切菜,但是后来我自己也开始做了,我觉得做的还不错,上次做了一个fashion的可乐鸡翅,大家感觉很不错,呵呵&#8230;&#8230;<br />
就中午吃饭而言,我得出一个结论,经常自带午饭的就是结婚的,偶尔自带午饭的就是有对象的,但是不是所有有对象的男士都自带午饭,也有像我们老师这样,只有自己一个人吃饭的,他说他很孤独,每天都一个人去吃午饭,因为他对象不给他做饭&#8230;&#8230;嘿嘿<br />
最近天气开始热了,夏天要开始了,这么热的天怎么过呢&#8230;&#8230;This is a question&#8230;&#8230;</p>
<p><a href="http://fantaci.org/archives/667">Kivi有话说</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/667/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>[ 个人生活]今天回到上海，正式工作</title>
		<link>http://fantaci.org/archives/665</link>
		<comments>http://fantaci.org/archives/665#comments</comments>
		<pubDate>Mon, 28 Jun 2010 07:07:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://fantaci.org/archives/665</guid>
		<description><![CDATA[今天回到上海，正式工作
[ 个人生活]今天回到上海，正式工作 is a post from fantaci.org and cg45.cn
<p><a href="http://fantaci.org/archives/665">[ 个人生活]今天回到上海，正式工作</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>今天回到上海，正式工作</p>
<p><a href="http://fantaci.org/archives/665">[ 个人生活]今天回到上海，正式工作</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/665/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CG的博客已恢复访问，域名更换为Fantaci.org</title>
		<link>http://fantaci.org/archives/660</link>
		<comments>http://fantaci.org/archives/660#comments</comments>
		<pubDate>Fri, 11 Jun 2010 18:46:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://fantaci.org/archives/660</guid>
		<description><![CDATA[CG的博客之前由于受到和谐，被迫迁到国外，目前已恢复访问，域名更换为Fantaci.org，原域名CG45.CN,将在最近设置跳转，部分原有链接将失效。
为了达到更好的显示效果，将原有主题进行了压缩处理，减少了加载时间，欢迎测试和报告BUG。
CG的博客已恢复访问，域名更换为Fantaci.org is a post from fantaci.org and cg45.cn
<p><a href="http://fantaci.org/archives/660">CG的博客已恢复访问，域名更换为Fantaci.org</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>CG的博客之前由于受到和谐，被迫迁到国外，目前已恢复访问，域名更换为Fantaci.org，原域名CG45.CN,将在最近设置跳转，部分原有链接将失效。<br />
为了达到更好的显示效果，将原有主题进行了压缩处理，减少了加载时间，欢迎测试和报告BUG。</p>
<p><a href="http://fantaci.org/archives/660">CG的博客已恢复访问，域名更换为Fantaci.org</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/660/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[.Net]设置背景透明的窗体，GDI+绘制异形WINFORM</title>
		<link>http://fantaci.org/archives/658</link>
		<comments>http://fantaci.org/archives/658#comments</comments>
		<pubDate>Wed, 05 May 2010 07:47:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[技术分享]]></category>
		<category><![CDATA[程序设计]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[VB]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=658</guid>
		<description><![CDATA[在.Net环境下绘制矩形，椭圆形，三角形等形态的窗体是件很简单的事情，只要设置窗体的背景透明当你在窗体上绘制图形和控件时，是不会显示窗体的，这点MS的GDI+确实相比其他平台的实现方式更加方便和简单。

设置方式也很简单,首先设置FORM的BackColor为一个程序中不常用的颜色，
然后再设置FORM的TransparenceKey为这个颜色就OK了<p><a href="http://fantaci.org/archives/658">[.Net]设置背景透明的窗体，GDI+绘制异形WINFORM</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>在.Net环境下绘制矩形，椭圆形，三角形等形态的窗体是件很简单的事情，只要设置窗体的背景透明当你在窗体上绘制图形和控件时，是不会显示窗体的，这点MS的GDI+确实相比其他平台的实现方式更加方便和简单。</p>
<p>设置方式也很简单,首先设置FORM的BackColor为一个程序中不常用的颜色，<br />
然后再设置FORM的TransparenceKey为这个颜色就OK了<br />
VB.net</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6581"><td class="code" id="p658code1"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> Form1_Load(<span style="color: #000080;">ByVal</span> sender <span style="color: #000080;">As</span> System.<span style="color: #000080;">Object</span>, _
 <span style="color: #000080;">ByVal</span> e <span style="color: #000080;">As</span> System.EventArgs) Handles MyBase.Load
	<span style="color: #008000;">'设置背景
</span>        Me.BackColor = Color.Black
	<span style="color: #008000;">'设置透明
</span>        Me.TransparencyKey = Color.Black
<span style="color: #000080;">end</span> <span style="color: #000080;">sub</span></pre></td></tr></table></div>

<p>C#.net</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6582"><td class="code" id="p658code2"><pre class="csharp" style="font-family:monospace;">        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> Form1_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">BackColor</span> <span style="color: #008000;">=</span> Color.<span style="color: #0000FF;">Black</span>
            <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">TransparencyKey</span>  <span style="color: #008000;">=</span> Color.<span style="color: #0000FF;">Black</span> 
        <span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://fantaci.org/archives/658">[.Net]设置背景透明的窗体，GDI+绘制异形WINFORM</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/658/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[源代码]使用VB.Net GDI+编程编写的3D魔方游戏程序</title>
		<link>http://fantaci.org/archives/656</link>
		<comments>http://fantaci.org/archives/656#comments</comments>
		<pubDate>Wed, 05 May 2010 07:44:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[技术分享]]></category>
		<category><![CDATA[源程序]]></category>
		<category><![CDATA[程序设计]]></category>
		<category><![CDATA[.Net]]></category>
		<category><![CDATA[GDI+]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[源代码]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=656</guid>
		<description><![CDATA[
最近学习了.net下的GDI+编程，下面小秀一下成果，使用GDI+编写的桌面魔方程序，今天把源代码放上，欢迎大家下载，如果机器上有.net环境的话可以直接运行bin目录下的MagicCube.exe进行游戏。<p><a href="http://fantaci.org/archives/656">[源代码]使用VB.Net GDI+编程编写的3D魔方游戏程序</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>最近学习了.net下的GDI+编程，下面小秀一下成果，使用GDI+编写的桌面魔方程序，今天把源代码放上，欢迎大家下载，如果机器上有.net环境的话可以直接运行bin目录下的MagicCube.exe进行游戏。</p>
<p>源代码下载地址<br />
<a href="http://www.fantaci.org/code/magiccube/magiccube.zip" target="_blank">http://www.fantaci.org/code/magiccube/magiccube.zip</a></p>
<p>下面方式几个重要的算法程序<br />
1，魔方正面九宫格90度翻转，这个只要细心观察翻转前和翻转后的魔方，你就可以得到答案<br />
左转90度：以(0,0)(2,2)为对称轴翻转后，再以(1,0)(1,2)为对称轴翻转<br />
右转90度：以(0,2)(2,0)为对称轴翻转后，再以(1,0)(1,2)为对称轴翻转<br />
算法如下：</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6563"><td class="code" id="p656code3"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">'正方形数据交换
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> RevertRectangleLeft(<span style="color: #000080;">ByVal</span> id <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>)
&nbsp;
        <span style="color: #008000;">'要实现左转90度
</span>        <span style="color: #008000;">'先对角线转置
</span>        <span style="color: #000080;">Dim</span> i, j <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        <span style="color: #000080;">For</span> i = 1 <span style="color: #000080;">To</span> Me.DIMCOUNT - 1
            <span style="color: #000080;">For</span> j = 0 <span style="color: #000080;">To</span> i - 1
                <span style="color: #008000;">'交换数据
</span>                <span style="color: #000080;">Dim</span> temp <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
                temp = Me.Matrix3D(id)(i)(j)
                Me.Matrix3D(id)(i)(j) = Me.Matrix3D(id)(j)(i)
                Me.Matrix3D(id)(j)(i) = temp
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
        <span style="color: #008000;">''后水平翻转
</span>        <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> Me.DIMCOUNT - 1
            <span style="color: #008000;">'交换数据
</span>            <span style="color: #000080;">Dim</span> temp <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
            temp = Me.Matrix3D(id)(0)(i)
            Me.Matrix3D(id)(0)(i) = Me.Matrix3D(id)(Me.DIMCOUNT - 1)(i)
            Me.Matrix3D(id)(Me.DIMCOUNT - 1)(i) = temp
        <span style="color: #000080;">Next</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
    <span style="color: #008000;">'正方形数据交换
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> RevertRectangleRight(<span style="color: #000080;">ByVal</span> id <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>)
&nbsp;
        <span style="color: #008000;">'要实现右转90度
</span>        <span style="color: #008000;">'先对角线转置
</span>        <span style="color: #000080;">Dim</span> i, j <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> Me.DIMCOUNT - 1
            <span style="color: #000080;">For</span> j = 0 <span style="color: #000080;">To</span> Me.DIMCOUNT - 1 - i - 1
                <span style="color: #008000;">'交换数据
</span>                <span style="color: #000080;">Dim</span> temp <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
                temp = Me.Matrix3D(id)(i)(j)
                Me.Matrix3D(id)(i)(j) = Me.Matrix3D(id)(Me.DIMCOUNT - 1 - j)(Me.DIMCOUNT - 1 - i)
                Me.Matrix3D(id)(Me.DIMCOUNT - 1 - j)(Me.DIMCOUNT - 1 - i) = temp
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
        <span style="color: #008000;">''后水平翻转
</span>        <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> Me.DIMCOUNT - 1
            <span style="color: #008000;">'交换数据
</span>            <span style="color: #000080;">Dim</span> temp <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
            temp = Me.Matrix3D(id)(0)(i)
            Me.Matrix3D(id)(0)(i) = Me.Matrix3D(id)(Me.DIMCOUNT - 1)(i)
            Me.Matrix3D(id)(Me.DIMCOUNT - 1)(i) = temp
        <span style="color: #000080;">Next</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></td></tr></table></div>

<p>2,魔方正面的4个侧面的翻转，这个实现相对较难，方法也很多，CG这里使用了队列保存所有方块信息，然后再次存回数组的方式来实现，另外为了统一方向，CG使用了面相交边的参数来控制队列的进出，实现比较复杂，但是可以节省很多控件，如果大家有好的方法，欢迎分享</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6564"><td class="code" id="p656code4"><pre class="vb" style="font-family:monospace;">    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 初始化各个面对应的边
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> InitEdge()
        <span style="color: #008000;">'+/- 10 + 100 + 1000 + X 用于记录对应变的交换方式
</span>        <span style="color: #008000;">'+/- 表示交换方式，顺序和逆序
</span>        <span style="color: #008000;">'10 表示 x 的位置 x = 0 或 x = DIMCOUNT
</span>        <span style="color: #008000;">'100 表示 y 的位置 y = 0 或 y = DIMCOUNT
</span>        <span style="color: #008000;">'1000 表示 xy的方向 =0 y++ =1000 x++
</span>        Edge(0) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {-12, 101, 1003, -1004}
        Edge(1) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {-1002, -1005, -1003, -1000}
        Edge(2) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {-15, 1, 0, 4}
        Edge(3) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {-10, -11, 5, -14}
        Edge(4) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {1102, 1100, 1103, 1105}
        Edge(5) = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(3) {-13, -1001, 2, 1104}
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 边数据交换
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;param name=&quot;id&quot;&gt;&lt;/param&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> RevertEdgeRight(<span style="color: #000080;">ByVal</span> id <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>)
        <span style="color: #008000;">'获取边数据
</span>        <span style="color: #000080;">Dim</span> edges() <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        edges = Me.Edge(id)
        <span style="color: #000080;">Dim</span> x, y, z, d <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        <span style="color: #008000;">'临时队列数组
</span>        <span style="color: #000080;">Dim</span> queue() <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        queue = <span style="color: #000080;">New</span> <span style="color: #000080;">Integer</span>(4 * DIMCOUNT - 1) {}
&nbsp;
        <span style="color: #000080;">Dim</span> edge1 <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
&nbsp;
        <span style="color: #000080;">Dim</span> m, i, j <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        <span style="color: #000080;">Dim</span> count <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> = 0
&nbsp;
        <span style="color: #008000;">'存入临时数组
</span>        <span style="color: #000080;">For</span> m = 0 <span style="color: #000080;">To</span> 3
&nbsp;
            <span style="color: #008000;">'需要交换边
</span>            edge1 = edges(m)
&nbsp;
            <span style="color: #008000;">'获取交换行号与列号
</span>            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 1000)) = 1 <span style="color: #000080;">Then</span>
                z = 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 1000
            <span style="color: #000080;">Else</span>
                z = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 100)) = 1 <span style="color: #000080;">Then</span>
                y = DIMCOUNT - 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 100
            <span style="color: #000080;">Else</span>
                y = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 10)) = 1 <span style="color: #000080;">Then</span>
                x = DIMCOUNT - 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 10
            <span style="color: #000080;">Else</span>
                x = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #000080;">Dim</span> sg = Math.Sign(edge1)
&nbsp;
            <span style="color: #000080;">If</span> sg = 0 <span style="color: #000080;">Then</span>
                sg = 1
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #008000;">'获取符号
</span>            <span style="color: #000080;">If</span> sg = 1 <span style="color: #000080;">Then</span>
                d = 0
            <span style="color: #000080;">Else</span>
                d = 1
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #008000;">'存入临时数组
</span>            <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
                <span style="color: #000080;">If</span> z = 0 <span style="color: #000080;">Then</span>
                    queue(m * DIMCOUNT + i) = _
                        Me.Matrix3D(Math.Abs(edge1))(x)(d * (DIMCOUNT - 1) + sg * i)
                <span style="color: #000080;">Else</span>
                    queue(m * DIMCOUNT + i) = _
                        Me.Matrix3D(Math.Abs(edge1))(d * (DIMCOUNT - 1) + sg * i)(y)
                <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
        <span style="color: #008000;">'交换后存回
</span>        <span style="color: #008000;">'存入临时数组
</span>        <span style="color: #000080;">For</span> m = 0 <span style="color: #000080;">To</span> 3
            <span style="color: #008000;">'需要交换边
</span>            edge1 = edges(m)
            <span style="color: #008000;">'获取交换行号与列号
</span>            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 1000)) = 1 <span style="color: #000080;">Then</span>
                z = 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 1000
            <span style="color: #000080;">Else</span>
                z = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 100)) = 1 <span style="color: #000080;">Then</span>
                y = DIMCOUNT - 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 100
            <span style="color: #000080;">Else</span>
                y = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
            <span style="color: #000080;">If</span> Math.Floor(Math.Abs(edge1 / 10)) = 1 <span style="color: #000080;">Then</span>
                x = DIMCOUNT - 1
                edge1 = edge1 <span style="color: #000080;">Mod</span> 10
            <span style="color: #000080;">Else</span>
                x = 0
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #008000;">'获取符号
</span>            <span style="color: #000080;">Dim</span> sg = Math.Sign(edge1)
&nbsp;
            <span style="color: #000080;">If</span> sg = 0 <span style="color: #000080;">Then</span>
                sg = 1
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #008000;">'获取方向
</span>            <span style="color: #008000;">'d =  Math.Sign(edge1) == 1 ? 0 : -1
</span>            <span style="color: #000080;">If</span> sg = 1 <span style="color: #000080;">Then</span>
                d = 0
            <span style="color: #000080;">Else</span>
                d = 1
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #008000;">'存回
</span>            <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
                <span style="color: #000080;">If</span> z = 0 <span style="color: #000080;">Then</span>
                    Me.Matrix3D(Math.Abs(edge1))(x)(d * (DIMCOUNT - 1) + sg * i) = _
                        queue(((1 + m) <span style="color: #000080;">Mod</span> 4) * DIMCOUNT + i)
                <span style="color: #000080;">Else</span>
                    Me.Matrix3D(Math.Abs(edge1))(d * (DIMCOUNT - 1) + sg * i)(y) = _
                        queue(((1 + m) <span style="color: #000080;">Mod</span> 4) * DIMCOUNT + i)
                <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></td></tr></table></div>

<p>3,绘制菱形,简单的点到点数组</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6565"><td class="code" id="p656code5"><pre class="vb" style="font-family:monospace;">    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 增加菱形，用于魔方侧面
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> AddPolygons()
&nbsp;
        <span style="color: #008000;">'定义点阵数组
</span>        <span style="color: #000080;">Dim</span> pts() <span style="color: #000080;">As</span> PointF
        <span style="color: #008000;">'绘制上边矩形
</span>        <span style="color: #000080;">Dim</span> i, j <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
        <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
            <span style="color: #000080;">For</span> j = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
                pts = AddPolygonPath1(<span style="color: #000080;">New</span> Point(POSTION.X + i * CUBEH + j * POLYH, _
                                            POSTION.Y - j * POLYH))
                <span style="color: #008000;">'获取填充内容，并绘制
</span>                GR.FillPolygon(Me.GetColorById(2, DIMCOUNT - 1 - j, i), pts)
                GR.DrawPolygon(OUTLINE, pts)
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
&nbsp;
        <span style="color: #008000;">'绘制左边矩形
</span>        <span style="color: #000080;">For</span> i = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
            <span style="color: #000080;">For</span> j = 0 <span style="color: #000080;">To</span> DIMCOUNT - 1
                pts = AddPolygonPath2(<span style="color: #000080;">New</span> Point(POSTION.X + DIMCOUNT * CUBEH + i * POLYH, _
                                        POSTION.Y + j * CUBEH - i * POLYH))
                <span style="color: #008000;">'获取填充内容，并绘制
</span>                GR.FillPolygon(Me.GetColorById(4, j, i), pts)
                GR.DrawPolygon(OUTLINE, pts)
            <span style="color: #000080;">Next</span>
        <span style="color: #000080;">Next</span>
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span>
&nbsp;
    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 绘制横向菱形，通过起点参数，获取菱形四个定点坐标
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> AddPolygonPath1(<span style="color: #000080;">ByVal</span> pt <span style="color: #000080;">As</span> Point) <span style="color: #000080;">As</span> PointF()
        <span style="color: #000080;">Dim</span> pts(3) <span style="color: #000080;">As</span> PointF
        pts(0) = pt
        pts(1) = <span style="color: #000080;">New</span> Point(pt.X + POLYH, pt.Y - POLYH)
        pts(2) = <span style="color: #000080;">New</span> Point(pt.X + CUBEH + POLYH, pt.Y - POLYH)
        pts(3) = <span style="color: #000080;">New</span> Point(pt.X + CUBEH, pt.Y)
        Return pts
    <span style="color: #000080;">End</span> <span style="color: #000080;">Function</span>
&nbsp;
    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 绘制在竖向菱形，通过起点参数，获取菱形四个定点坐标
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;param name=&quot;pt&quot;&gt;&lt;/param&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Function</span> AddPolygonPath2(<span style="color: #000080;">ByVal</span> pt <span style="color: #000080;">As</span> Point) <span style="color: #000080;">As</span> PointF()
        <span style="color: #000080;">Dim</span> pts(3) <span style="color: #000080;">As</span> PointF
        pts(0) = pt
        pts(1) = <span style="color: #000080;">New</span> Point(pt.X + POLYH, pt.Y - POLYH)
        pts(2) = <span style="color: #000080;">New</span> Point(pt.X + POLYH, pt.Y + CUBEH - POLYH)
        pts(3) = <span style="color: #000080;">New</span> Point(pt.X, pt.Y + CUBEH)
        Return pts
    <span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></td></tr></table></div>

<p>下面是演示效果<br />
<img src="http://www.fantaci.org/code/magiccube/magiccube.JPG" alt="3D魔方游戏" /></p>
<p><a href="http://fantaci.org/archives/656">[源代码]使用VB.Net GDI+编程编写的3D魔方游戏程序</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/656/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[设计模式]单例（Singleton）设计模式的几种实现和比较</title>
		<link>http://fantaci.org/archives/652</link>
		<comments>http://fantaci.org/archives/652#comments</comments>
		<pubDate>Wed, 28 Apr 2010 02:52:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[源代码]]></category>
		<category><![CDATA[设计模式]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=652</guid>
		<description><![CDATA[单例（Singleton）设计模式有很多写法，
不同的写法往往效率有所不同，下面使
用JAVA语言实现几种常用的单例实现，
与大家分享。

单例模式的实现原理也很简单，首先通
过私有化对象构造方法，不允许外部创
建对象，然后通过对象内部创建对象的
实例，外部对象调用对象公开的实例获
取方法获取实例，并且，对象的实例化
过程只有一次，因而称为单例。<p><a href="http://fantaci.org/archives/652">[设计模式]单例（Singleton）设计模式的几种实现和比较</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>单例（Singleton）设计模式有很多写法，<br />
不同的写法往往效率有所不同，下面使<br />
用JAVA语言实现几种常用的单例实现，<br />
与大家分享。</p>
<p>单例模式的实现原理也很简单，首先通<br />
过私有化对象构造方法，不允许外部创<br />
建对象，然后通过对象内部创建对象的<br />
实例，外部对象调用对象公开的实例获<br />
取方法获取实例，并且，对象的实例化<br />
过程只有一次，因而称为单例。</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6526"><td class="code" id="p652code6"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 0.曾经...
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton ins <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 1.直接初始化对象，适合小对象的单例，无需同步
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton ins <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 2.强制同步，线程安全，运行时控制同步，速度较慢
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton ins <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>		
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span>  Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 3.方法1的改进方法，只有在第一次使用时才创建对象
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton ins <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">static</span>
	<span style="color: #009900;">&#123;</span>
		ins <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 4.两次比较算法，手动控制同步
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Singleton
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton ins <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Singleton getInstance<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">==</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//再次比较</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span> <span style="color: #339933;">==</span> Singleton.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">ins</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> Singleton<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><a href="http://fantaci.org/archives/652">[设计模式]单例（Singleton）设计模式的几种实现和比较</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/652/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[算法]IBM技术的面试题使用递归位运算实现字节位反转(RBIT)</title>
		<link>http://fantaci.org/archives/647</link>
		<comments>http://fantaci.org/archives/647#comments</comments>
		<pubDate>Tue, 27 Apr 2010 08:26:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[技术分享]]></category>
		<category><![CDATA[源程序]]></category>
		<category><![CDATA[算法与ACM]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[VB]]></category>
		<category><![CDATA[算法]]></category>
		<category><![CDATA[面试]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=647</guid>
		<description><![CDATA[字节的中心转置反转，这是一道悲剧的IBM技术面试题，原因很简单，CG没有做对
我把它当成针对位的高低转置题目来做了，结果很简单，直接被拒，悲剧的是，CG
在面试过程中还不住的跟面试官谈论怎么实现高低转置效率最高，等到出来的时候
才被IBM面试官提醒，悲剧。<p><a href="http://fantaci.org/archives/647">[算法]IBM技术的面试题使用递归位运算实现字节位反转(RBIT)</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>字节的中心转置反转，这是一道悲剧的IBM技术面试题，原因很简单，CG没有做对<br />
我把它当成针对位的高低转置题目来做了，结果很简单，直接被拒，悲剧的是，CG<br />
在面试过程中还不住的跟面试官谈论怎么实现高低转置效率最高，等到出来的时候<br />
才被IBM面试官提醒，悲剧。</p>
<p>原题如下：<br />
给定一个任意字节长度的数据（以一个Byte为例），要求实现数据的位中心翻转，<br />
也就是数据的对称位数据交换，比如：<br />
1010 1100 -> 0011 0101<br />
1111 1111 -> 1111 1111<br />
0000 0000 -> 0000 0000<br />
1111 0000 -> 0000 1111</p>
<p>解题思路也很简单，只要使用位运算实现以下的位变化即可，但是需要考虑到其他<br />
位的情况，注意运算符的使用即可，这个在ARM CPU的DSP指令集中是RBIT指令，<br />
单个字节内按位反转，IBM不愧是IBM<br />
11 &#8211; > 11<br />
00 &#8211; > 00<br />
10 &#8211; > 01<br />
01 &#8211; > 10</p>
<p>以下是C语言和VB.net语言的两种解题实现的代码，VB涉及位转换，效率较低<br />
，但是算法是一样的，同时，这里使用了递归算法</p>
<p>VB.net</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6477"><td class="code" id="p647code7"><pre class="vb" style="font-family:monospace;">    <span style="color: #008000;">'全局变量，保存需要转换的数据
</span>    <span style="color: #000080;">Private</span> val <span style="color: #000080;">As</span> <span style="color: #000080;">Byte</span>
&nbsp;
    <span style="color: #008000;">''' &lt;summary&gt;
</span>    <span style="color: #008000;">''' 核心算法，使用递归实现一个Byte的字节中心转置
</span>    <span style="color: #008000;">''' &lt;/summary&gt;
</span>    <span style="color: #008000;">''' &lt;param name=&quot;a&quot;&gt;&lt;/param&gt;
</span>    <span style="color: #008000;">''' &lt;remarks&gt;&lt;/remarks&gt;
</span>    <span style="color: #000080;">Private</span> <span style="color: #000080;">Sub</span> fun(<span style="color: #000080;">ByVal</span> a <span style="color: #000080;">As</span> <span style="color: #000080;">Byte</span>)
        <span style="color: #000080;">If</span> a = 0 <span style="color: #000080;">Then</span>
            <span style="color: #000080;">Exit</span> <span style="color: #000080;">Sub</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #008000;">'11 - &gt; 11
</span>        <span style="color: #008000;">'00 - &gt; 00
</span>        <span style="color: #008000;">'10 - &gt; 01
</span>        <span style="color: #008000;">'01 - &gt; 10
</span>        <span style="color: #008000;">'算法在于排除11和00的情况，01和10反转
</span>        <span style="color: #008000;">'排除and之后全是0的情况
</span>        <span style="color: #000080;">If</span> (val <span style="color: #000080;">And</span> a) &lt;&gt; (<span style="color: #000080;">CByte</span>(128 / a) <span style="color: #000080;">And</span> val) <span style="color: #000080;">Then</span>
            <span style="color: #008000;">'其中一个为0，另一个必为1 ， 全1的情况自然排除
</span>            <span style="color: #000080;">If</span> (val <span style="color: #000080;">And</span> a) = 0 <span style="color: #000080;">Or</span> (<span style="color: #000080;">CByte</span>(128 / a) <span style="color: #000080;">And</span> val) = 0 <span style="color: #000080;">Then</span>
                <span style="color: #008000;">'进行位运算
</span>                val = <span style="color: #000080;">CByte</span>(val <span style="color: #000080;">Xor</span> (a + <span style="color: #000080;">CByte</span>(128 / a)))
            <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
        <span style="color: #008000;">'递归调用
</span>        fun(a / 2)
    <span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></td></tr></table></div>

<p>C/C++</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6478"><td class="code" id="p647code8"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//C语言实现一个Byte的字节中心转置</span>
<span style="color: #339933;">#include &lt;STDIO.H&gt;</span>
<span style="color: #339933;">#include &lt;MATH.H&gt;</span>
&nbsp;
<span style="color: #339933;">#define BYTE 8</span>
<span style="color: #666666; font-style: italic;">//#define INTEGER 16</span>
&nbsp;
<span style="color: #339933;">#define LENGTH BYTE</span>
<span style="color: #666666; font-style: italic;">//#define LENGTH INTEGER</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//求出算子，用于参数传递</span>
<span style="color: #339933;">#define ARGUMENT pow(2 , (LENGTH / 2 - 1))</span>
<span style="color: #666666; font-style: italic;">//#define ARGUMENT 1 &lt;&lt; ( LENGTH/2 -1 ) </span>
&nbsp;
<span style="color: #339933;">#define HIGHT 0x80	/*1000 0000*/</span>
<span style="color: #666666; font-style: italic;">//#define HIGHT 0x8000	/*1000 0000 0000 0000*/</span>
&nbsp;
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">short</span> val <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//unsigned int val = 0;</span>
&nbsp;
<span style="color: #993333;">int</span> fun<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> a<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//a为空，返回</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span> <span style="color: #339933;">==</span> a<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">//'11 - &gt; 11</span>
	<span style="color: #666666; font-style: italic;">//'00 - &gt; 00</span>
	<span style="color: #666666; font-style: italic;">//'10 - &gt; 01</span>
	<span style="color: #666666; font-style: italic;">//'01 - &gt; 10</span>
	<span style="color: #666666; font-style: italic;">//'算法在于排除11和00的情况，01和10反转</span>
	<span style="color: #666666; font-style: italic;">//'排除and之后全是0的情况</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">&amp;</span> a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>HIGHT <span style="color: #339933;">/</span> a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//其中一个为0，另一个必为1 ， 全1的情况自然排除</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span>val <span style="color: #339933;">&amp;</span> a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>HIGHT <span style="color: #339933;">/</span> a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span> val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//进行位运算</span>
			val <span style="color: #339933;">=</span> val <span style="color: #339933;">^</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>HIGHT <span style="color: #339933;">/</span> a<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	fun<span style="color: #009900;">&#40;</span>a <span style="color: #339933;">/</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//func(a &gt;&gt; 1);</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc <span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//输入</span>
	scanf<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//递归调用</span>
	fun<span style="color: #009900;">&#40;</span>ARGUMENT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//输出</span>
	<a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%d&quot;</span><span style="color: #339933;">,</span> val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>完整代码下载<br />
<a href="http://www.fantaci.org/code/bytecvt/src.zip" target="_blank" title="字节的中心转</p>
<p>置反转">http://www.fantaci.org/code/bytecvt/src.zip</a><br />
VB运行效果<br />
<img src="http://www.fantaci.org/code/bytecvt/bytecvt.JPG" /><br />
非递归算法可参照</p>
<p>http://blog.zol.com.cn/1386/article_1385054.html</p>
<p><a href="http://fantaci.org/archives/647">[算法]IBM技术的面试题使用递归位运算实现字节位反转(RBIT)</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/647/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[JS]使用JavaScript编写和实现的可变动态密码输入键盘控件</title>
		<link>http://fantaci.org/archives/642</link>
		<comments>http://fantaci.org/archives/642#comments</comments>
		<pubDate>Mon, 26 Apr 2010 02:53:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[技术分享]]></category>
		<category><![CDATA[源程序]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[分享]]></category>
		<category><![CDATA[源代码]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=642</guid>
		<description><![CDATA[今天要分享的是CG做的一个简单的JavaScript编写和实现的可变动态密码
输入控件，可以动态的生产数字键盘并显示，并且可以实现每次点击后密
码键盘重新加载，可以手动控制隐藏和显示，手动控制刷新等功能。

相信经常登陆网上银行或者某些游戏网站的朋友应该会经常看到这个控件
，其实实现起来原理并不复杂，主要是通过随机生产数字，然后通过hash
算法，安排数字的位置，CG这里用了最简单的占位算法，虽然效率比较低
（o(n^2)),但是处理10个数字（最差是55次）是足够的,如果带上字母键盘
和特殊字符的话，建议更换算法。<p><a href="http://fantaci.org/archives/642">[JS]使用JavaScript编写和实现的可变动态密码输入键盘控件</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>最近CG在上海冈三华大公司实习，也算是上岗前的试用，除了平时在公司<br />
上网受到限制无法与外界取得联系之外，目前状况一切良好，请诸位不用<br />
担心，CG在此谢过！</p>
<p>今天要分享的是CG做的一个简单的JavaScript编写和实现的可变动态密码<br />
输入控件，可以动态的生产数字键盘并显示，并且可以实现每次点击后密<br />
码键盘重新加载，可以手动控制隐藏和显示，手动控制刷新等功能。</p>
<p>相信经常登陆网上银行或者某些游戏网站的朋友应该会经常看到这个控件<br />
，其实实现起来原理并不复杂，主要是通过随机生产数字，然后通过hash<br />
算法，安排数字的位置，CG这里用了最简单的占位算法，虽然效率比较低<br />
（o(n^2)),但是处理10个数字（最差是55次）是足够的,如果带上字母键盘<br />
和特殊字符的话，建议更换算法。</p>
<p>如果大家对以下的代码或说明有所疑问的话，欢迎留言。</p>
<p>优先占位算法初始动态密码键盘代码如下：</p>

<div class="wp_codebox"><table width="100%" ><tr id="p6429"><td class="code" id="p642code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//初始化数字键盘</span>
<span style="color: #003366; font-weight: bold;">function</span> initNum<span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> strHtml <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> line <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #006600; font-style: italic;">//编制随机数组</span>
  <span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//取0-9之间的整数</span>
    <span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//遍历数组找到空位</span>
    <span style="color: #003366; font-weight: bold;">var</span> flag <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arr.<span style="color: #660066;">length</span> <span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            flag <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>flag<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        arr<span style="color: #009900;">&#91;</span>arr.<span style="color: #660066;">length</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> num<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>以下是全部的JS代码，因为是简单实现，所以就不做对象封装了</p>

<div class="wp_codebox"><table width="100%" ><tr id="p64210"><td class="code" id="p642code10"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//定义全局容器ID</span>
<span style="color: #003366; font-weight: bold;">var</span> OBJID <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;layerDisplay&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//对象选择器</span>
<span style="color: #003366; font-weight: bold;">function</span> $<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//加载键盘控件</span>
<span style="color: #003366; font-weight: bold;">function</span> load<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> OBJID<span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//控制内部HTML</span>
  $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//重新加载空间库</span>
  $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> getControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//显示</span>
  $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//隐藏</span>
<span style="color: #003366; font-weight: bold;">function</span> hide<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> OBJID<span style="color: #339933;">;</span>
  $<span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;none&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//获取控件</span>
<span style="color: #003366; font-weight: bold;">function</span> getControl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> strHtml <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//初始化键盘</span>
  strHtml <span style="color: #339933;">+=</span> initNum<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//OK按钮</span>
  strHtml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>button<span style="color: #000099; font-weight: bold;">\&quot;</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span>btnReload<span style="color: #000099; font-weight: bold;">\&quot;</span> name=<span style="color: #000099; font-weight: bold;">\&quot;</span>btnReload<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>Rest<span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>command<span style="color: #000099; font-weight: bold;">\&quot;</span> onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span>load()<span style="color: #000099; font-weight: bold;">\&quot;</span>/&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//隐藏按钮 </span>
  strHtml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>button<span style="color: #000099; font-weight: bold;">\&quot;</span> id=<span style="color: #000099; font-weight: bold;">\&quot;</span>btnHide<span style="color: #000099; font-weight: bold;">\&quot;</span> name=<span style="color: #000099; font-weight: bold;">\&quot;</span>btnHide<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>Hide<span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>command<span style="color: #000099; font-weight: bold;">\&quot;</span> onclick=<span style="color: #000099; font-weight: bold;">\&quot;</span>hide()<span style="color: #000099; font-weight: bold;">\&quot;</span>/&gt;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//设置按钮并显示</span>
  <span style="color: #000066; font-weight: bold;">return</span> strHtml<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addNum<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> strVal <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
  <span style="color: #006600; font-style: italic;">//空对象</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">==</span> obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> 
  <span style="color: #006600; font-style: italic;">//空字符串,或不合法字符串</span>
  strVal <span style="color: #339933;">=</span> obj.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #339933;">==</span> strVal 
      <span style="color: #339933;">||</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">==</span> strVal.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span> 
  <span style="color: #006600; font-style: italic;">//追加字符</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;txtDisplay&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">+=</span> strVal
  <span style="color: #006600; font-style: italic;">//</span>
  load<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//初始化数字键盘</span>
<span style="color: #003366; font-weight: bold;">function</span> initNum<span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> strHtml <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> arr <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">||</span> line <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #006600; font-style: italic;">//编制随机数组</span>
  <span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>arr.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">//取0-9之间的整数</span>
    <span style="color: #003366; font-weight: bold;">var</span> num <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">*</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//遍历数组找到空位</span>
    <span style="color: #003366; font-weight: bold;">var</span> flag <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arr.<span style="color: #660066;">length</span> <span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> num<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            flag <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>flag<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        arr<span style="color: #009900;">&#91;</span>arr.<span style="color: #660066;">length</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> num<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #006600; font-style: italic;">//输出按钮列表</span>
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">9</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     strHtml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;input type=<span style="color: #000099; font-weight: bold;">\&quot;</span>button<span style="color: #000099; font-weight: bold;">\&quot;</span> class=<span style="color: #000099; font-weight: bold;">\&quot;</span>number<span style="color: #000099; font-weight: bold;">\&quot;</span> value=<span style="color: #000099; font-weight: bold;">\&quot;</span>'</span>
             <span style="color: #339933;">+</span> arr<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>
             <span style="color: #339933;">+</span> <span style="color: #3366CC;">'<span style="color: #000099; font-weight: bold;">\&quot;</span> onclick = <span style="color: #000099; font-weight: bold;">\&quot;</span>addNum(this)<span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;'</span><span style="color: #339933;">;</span>
          <span style="color: #006600; font-style: italic;">//控制换行</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">%</span> line<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        strHtml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">return</span> strHtml</pre></td></tr></table></div>

<p>以下是动态密码输入控件演示地址<br />
<a href = "http://www.fantaci.org/code/jspassctrl/jspassctrl.html" target="_blank" title="动态密码输入控件代码演示">http://www.fantaci.org/code/jspassctrl/jspassctrl.html</a></p>
<p>以下是动态密码输入控件演示效果图<br />
效果图1<br />
<img src="http://www.fantaci.org/code/jspassctrl/jspassctrl1.JPG" alt="动态密码输入控件" /><br />
效果图2<br />
<img src="http://www.fantaci.org/code/jspassctrl/jspassctrl2.JPG" alt="动态密码输入控件" /></p>
<p><a href="http://fantaci.org/archives/642">[JS]使用JavaScript编写和实现的可变动态密码输入键盘控件</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/642/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[个人生活]CG在上海第一个属于自己的周末</title>
		<link>http://fantaci.org/archives/640</link>
		<comments>http://fantaci.org/archives/640#comments</comments>
		<pubDate>Sun, 25 Apr 2010 05:08:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CG有话说]]></category>
		<category><![CDATA[个人生活]]></category>
		<category><![CDATA[OHS]]></category>
		<category><![CDATA[上海]]></category>

		<guid isPermaLink="false">http://www.fantaci.org/?p=640</guid>
		<description><![CDATA[时间过得很快，CG来上海已经快一个月了，不过之前因为ETP基地还有学校那边事情较多，前两个周末都忙得要死，本周周末才真正的有了属于自己的时间，还好在上海这个地方，对外联系还是很方便的网吧不是很难找，现在CG正在网吧完成这篇POST，主要是介绍一下CG目前所在公司的基本情况,还有就是发布一下最新的联系信息，便于大家跟我联系。<p><a href="http://fantaci.org/archives/640">[个人生活]CG在上海第一个属于自己的周末</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></description>
			<content:encoded><![CDATA[<p>时间过得很快，CG来上海已经快一个月了，不过之前因为ETP基地还有学校那边事情较多，前两个周末都忙得要死，本周周末才真正的有了属于自己的时间，还好在上海这个地方，对外联系还是很方便的网吧不是很难找，现在CG正在网吧完成这篇POST，主要是介绍一下CG目前所在公司的基本情况,还有就是发布一下最新的联系信息，便于大家跟我联系。</p>
<p>首先就是联系方式得更新，主要是手机号码，如果知道我以前手机号码的朋友，请注意及时更新。</p>
<p>再来介绍一下冈三华大(Okasan Huada),是一家中日合资的软件企业，以下内容取自公司网站(<a href="http://www.ohs-sys.com/">http://www.ohs-sys.com/</a>), 在这里放上，顺便为公司宣传宣传，做做SEO，呵呵，CG上周SEO了“冈三华大”这个关键字,效果不错，大家可以google一下试试</p>
<p>简体中文版</p>
<p>上海岡三華大计算机系统有限公司（以下简称OHS）成立于2005年7月，是日本岡三证券株式会社下属岡三情报系统株式会社与华东师范大学华大集团共同创建的软件开发公司。</p>
<p>????? OHS坐落于上海天地软件园内，是上海市信息化委员会认定的软件企业，已通过ISO9001质量管理体系、ISO27001信息安全管理体系相关认证。公司集计算机软件的研发和销售于一体，并提供技术咨询与服务，主要从事金融证券、电子商务、物流管理等领域软件的研究和开发。其前身为华东师范大学计算中心岡三开发组，至今已有15年的软件开发经验，拥有一大批具有丰富业务知识的高素质开发人员。 高水平的技术队伍，国际化的质量规范，丰富的业务知识，保证了OHS一直处于稳健高速的发展状态。公司现有员工320余人，其中系统工程师150余名，大部分具有海外工作经历，且长期从事金融证券、物流、电子商务方面的设计和开发。所服务过的用户遍及政府机关、金融系统、证券行业、财税系统、医疗系统、工商系统、电力系统、教育系统及企事业单位等。在企业信息化、过程自动化和城市信息化等领域具有一定的优势。<br />
?<br />
????? 面对持续发展的中国经济和迅速增长的信息化市场，公司成立以来，不断强化内部管理，逐步明确发展战略，着力提升综合能力与核心竞争能力，以企业信息化、海外软件合作为主力积极开拓市场，依托华东师范大学的丰富人才资源，始终坚持以客户的需求和满意为核心，大力发展软件外包和外包服务。目前已与岡三证券等著名跨国公司建立了长期稳定的业务往来，并于2009年9月在南通正式成立南通华岡计算机系统有限公司。南通分公司的成立进一步强化了公司的业务能力，推动了区域化服务的发展，将为南通及周边地区的客户带来更快的响应速度和更加完善的服务体系。?</p>
<p>日本語で<br />
?上海岡三華大計算機系統有限公司（以下略称OHS）は岡三証券株式会社の子会社である岡三情報システム株式会社（以下略称OIS）と上海華大（集団）有限公司に所属する華東師範大学の合弁会社として、2005年7月より発足しました。</p>
<p>????? 上海の「天地軟件園」に位置するOHSは、上海市情報委員会が認定させるソフトウェア企業であり、ISO9001、ISO27001の品質管理体系関係認証も取得致しました。当社の業務範囲としてコンピューターソフトウェアの研究、開発、販売を中心の基に、技術コンサルティングサービスも提供致しました。主に、金融証券、電子ビジネス、ロジスティッグス管理など多分野の研究と開発を行います。OHSの前身は華東師範大学コンピューターセンター岡三開発グループであり、今まで15年のソフトウェア開発経験を積んで、豊富な業務知識を持っているかつ高素質である開発要員も取り撮えております。 専門化の技術チーム、品質の国際標準化及び豊富な証券金融業務知識が基幹として、当社はずっと高速、穏健な発展状態を保持しております。現在、正社員は320名ほどの中に150名以上はシステムエンジニアであり、海外経験がある方も半数以上あります。長期に証券金融、ロジスティッグス、電子商取引方面の設計と開発を行い、政府機関、金融システム、証券業種、財税システム、医療システム、工商システム、電力システム、教育システム及び企業、機関部門などにサービスを提供致したことがあります。企業情報化、プロセス自動化、都市情報化分野にはるかに優勢を占めております。<br />
?<br />
????? 中国経済の急速な発展と情報化市場の高速成長に従って、OHSの成立以来、内部管理を強化し、次第に発展戦略明確化にし、絶えず綜合能力と核心競争力を高めています。企業情報化、海外ソフトウェア提携業務を中心として積極的にマーケット開拓しております。また、華東師範大学の人材を積極的に活用し、かわらずお客様のニーズを満足させることを目指し、ソフトウェアオフショア業務やオフショアサービスを中心に力を注いでおります。実績としては、岡三証券様等有名な多国籍な会社と長期安定なビジネスを確立しております。2009年9月より南通岡三華大計算機系統有限公司はOHSの子会社として南通市にて正式に成立しました。南通子会社の成立はOHSの業務能力を更に強化した上、地域化サービスの発展を推進しました。将来、南通及び周辺のお客様に更に高効果な返事スピードと完璧であるサービスシステムを提供すること目指します。</p>
<p><a href="http://fantaci.org/archives/640">[个人生活]CG在上海第一个属于自己的周末</a> is a post from <a href="http://fantaci.org">fantaci.org</a> and <a href="http://cg45.cn">cg45.cn</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fantaci.org/archives/640/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
