算法训练

刘先毅提到 现在的成绩与最初选拔时有很大的进步,练习是有意义的。
1.从有语法错语,无法调通程序到可以AC题目;
2.对提高工程能力有作用;
3.对其他科目实验有作用。关怡然提到 应该如何训练。
关健问题不在于理解与否,而在于速度。
1.反复做同一道典型题,直至可以在规定时间内完成某个算法。
  如在半小时写出最小生成树算法。
2.对比
  1)大量语法错误,需要实验语法;
  2)不知道某功能应用何种函数实现,函数的参数表,需要实验函数的执行效果(作用);
  3)不知道经典算法,需要现场考虑算法;
  4)不能熟练写出经典算法,需要现场调试。

什么才是完了(转载)

Shredder Home

一个探险家在热带雨林里被一群食人族土著包围了。
他想这下完蛋了,默念道:"上帝啊,我完了。"
"不,你还没有完,"这时天空暗了下来,一个声音从云中传来,
"捡起你身边的石头,把土著首领的脑袋砸开花。"
探险家用石头砸死了站在他面前的土著首领。
于是发现那100多个土著居民愤怒了。
"好,"那个声音又传来,"这下你才完了。"

神奇的英文字典WordNet(转载)

[http://www.centory.net/bencandy.php?fid=75&id=8911]


  WordNet是美国普林斯顿大学的心理学家、语言学家们共同研发的一套用以研究语言学的词汇参考系统。对一般用户而言,与其把WordNet理解为一 个语言学的科研项目,不如把它当作一个词典软件来用。WordNet的设计是仿照人对单词记忆与理解模式进行的,因此它对正在学习英语的中国学生显得很有 针对性。

  WordNet目前最新版本是2.0,可以在Windows和Unix平台下运行。用户可以到 http://wordnet.princeton.edu/wn2.0 免费下载、安装。(Windows平台的安装文件约12M)。

  软件的安装很简单,装好后大约需要占用39M的磁盘空间。软件提示和解释均为英文,但是用过词典类软件的用户应该很容易上手。软件的界面如上图所示,简直可以用"其貌不扬"来形容,不过可千万不要以貌取人啊……

   我们赶紧来看看WordNet的功能。举个简单的例子:我们首先在Search word框中输入一个人人都认识的单词"suit",立即得到6个名词词义(称为sense)和4个动词词义。其中名词词义之一"诉讼" (lawsuit, suit, case, cause, causa -- a comprehensive term for any proceeding in a court of law whereby an individual seeks a legal rem edy)是中国学生往往容易忽略的词义。既然它被WordNet列为第一位,让我们展开来看看,"suit是一类什么东西?"(点击按钮Noun,选择第 3项"suit is a kind of …", 。)(注:解释中出现的英文限于篇幅有删节,中文为笔者注。) 立即得到:

  Sense 1(词义1)

  lawsuit, suit, case, cause, causa -- 诉讼
  => proceeding, legal proceeding, proceedings -- 法律行动
  => due process, due process of law -- 预定的法律程序
  => group action -- 团体行为
  => act, human action, human activity -- 人类的行为
  => event -- 事件

  这下即使不看详细解释,suit一词的这个含义我们也掌握的八九不离十了吧。再让我们来看看"都有什么东西是suit(案件)?"(点选… is a kind of suit)

  Sense 1(词义1)
  lawsuit, suit, case, cause, causa -- 诉讼
  => civil suit --民事诉讼
  => class action, class-action suit -- 共同诉讼
  => countersuit -- 反诉
  => criminal suit -- 刑事诉讼
  => moot -- 假设案,被法律系学生用作练习辩论的假定案件
  => paternity suit, bastardy proceeding -- 生父确认诉讼

   出现的都是日常生活中经常听到却不知英文的词组,看到上面后便不觉得神秘了。"咦?假设案的英文就是moot,这么简单?……"长见识了吧!让我们再来 看看动词:"suit" 适合)的等价词汇(Coordinate Word,这可能是一种搜索引擎会利用到的算法,当一个关键词无法找到需要的内容时系统自动用另外的词来替代。)

  Sense 1

  suit, accommodate, fit -- (be agreeable or acceptable to) 适宜于
  -> meet, fit, conform to 适应,符合,遵照
  => coordinate 调整,使互相配合
  => fit the bill, fill the bill 正合需要
  => behoove, behove 应该、有必要
  => satisfy, fulfill, fulfil, live up to 满足,实现,实践
  => suit, accommodate, fit 合身

   这难道不比查专门的同义词词典更有效?还有更绝妙的:通常我们查询单词,都是输中文查英文,或者输英文查中文,英文与中文是对应的。然而,当我们不能准 确描述某个英文单词的中文名称时,或者词义过于生僻上述方法就失效了。不要怕!我们有WordNet来帮忙!

  我们想查"鬃毛" 的英文怎么说,不用去找动物学专业的汉英词典,只需在WordNet中输入"毛发"(hair),利用WordNet中的"哪些东西是……",即可得到 "mane"(第3项)。如果我们需要了解"三架马车"这句人们耳熟能详的中文对应的英文是哪个词,恐怕一般的字典是帮不上忙的。但我们都学过"马车"是 "carriage",再"哪些东西是……",便轻松查找到"troika"这个俄语外来语。同时还可以了解其他19种形形色色的马车。(如下图)这对扩 大词汇量来说是个不可多得的好机会。

  WordNet为什么查词这样强劲呢?原来语言专家认为,语言的词汇是按照同义词类组织在一起 的,每个词类都对应一种"潜在的概念",词类与词类之间通过不同的方式联系。WordNet正是基于这种想法编写的。这套系统中,英语单词被分为名词、动 词、形容词、副词四大类(单词可以跨类),每类对应不同的查询方法。名词有"什么是……",动词有"……是一种做什么的方法"等。
  此外,对于开发人员,WordNet还提供了一套编程接口,详情可参考它的网站。赶紧下载一套神奇的WordNet装到自己电脑上试一试吧!你也会有很多单词新发现的。

正确使用DataSet和DataReader(转载)

July 26, 2006
正确使用DataSet和DataReader
Filed under: SQL&DB AccessingBy Riven Huang 2006.07.26
参照
Why I Don't Use DataSets in My ASP.NET Applications(by Scott Michell)
http://aspnet.4guysfromrolla.com/articles/050405-1.aspxPerformance Comparison: Data Access Techniques
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/bdadotnetarch031.asp首先需要理解DataSet 和 DataReader的设计目标:
DataSet可以理解成一个小型的,存在于内存中的数据库,包含多个data table,table之间
可存在约束关系.
DataSet和数据库无关,由DataAdapter来负责对数据库的处理,一旦数据填充结束,就和数据库
断开连接.
DataSet对XML的支持比较好.DataReader可以理解成程序和数据库之间的桥梁.只能顺序的,从数据库中读取记录.
DataReader是和数据库相关的,所以存在sql, ole等多个版本的DataReader.从使用上来看,使用DataReader需要以下步骤:
// 1. 建立连接
SqlConnection myConnection = new SqlConnection(conn);// 2. 执行查询
SqlCommand myCommand = new SqlCommand(myConnection, sqlText);SqlReader myReader = myCommand.ExecuteReader();// 3. Read
while(myReader.Read())
{}// 4. Close connection
myConnection.Close();使用DataSet需要以下步骤:
// 1. 建立连接
SqlConnection myConnection = new SqlConnection(conn);// 2. 生成command 和 adapter
SqlCommand myCommand = new SqlCommand(myConnection, sqlText);
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);// 3. 生成dataset并填充
DataSet myDataSet = new DataSet();
myAdapter.Fill(myDataSet);// 4. Close connection
myConnection.Close();如果使用UIControlo显示数据,对于dataset和datareader的操作是相同的:
把dataset或datareader赋给control的DataSource属性,
再调用control的DataBind()方法.比较:
DataSet的性能比DataReader差很对,同时占用大量的内存.何时使用DataSet:
1.数据传输.
2.桌面应用.

Supreme Commander的配置

Minimum Requirements
CPU: Athlon 64 3000+/Intel 2.8ghz
Graphics: Nvidia 6600/X800GTO (SM 2.0)
RAM: 768Mb/1Gb on Windows Vista
HDD: 6GB
Internet: 256k+
Optical Drive: DVD
Software: DX9.0c with Windows XPRecommended Requirements
CPU: Dual-core CPU (Athlon X2/Pentium D)
Graphics: Nvidia 7800GTX/ATI X1800XT (SM 3.0) or DX10 equivalent
RAM: 1.5Gb
HDD: 6GB
Internet: 512k+ (128k+ upstream)
Optical Drive: DVD
Software: DX10 with Windows Vista
如果我的机器能够长大...它现在一定已经老得快不能自主呼吸了。

试了几个FireFox扩展

1.Better Gmail 0.6.1
  改皮肤的功能不错,鼠标到哪里,哪封信就加亮。
  label color
  macro
2.Clipmarks 2.0.4
  作用是方便选中网页中的某一处,然后复制。
  似乎让机器变慢了,且需要登录。禁用。
3.Download Statusbar 0.9.4.6
  在状态栏显示当前下载状态,可以停止/继续。
4.United States English Dictionary 2.0.0.6
 原以为是词霸类的软件。用于拼写检查。 禁用。
" This extension packages a subset of the original English wordlist created by Kevin Atkinson for Pspell and Aspell and thus is covered by his original LGPL license. The affix file is a heavily modified version of the original english.aff file which was released as part of Geoff Kuenning's Ispell and as such is covered by his BSD license."[ http://www.blogzilla.info/spellchecker/

Wordlist Creator(转载)

Wordlist Creator

via Freeware Home -- new additions on May 14, 2007

Wordlist Creator creates an alphabetical list of the words contained in a text file. Useful if you need to make a dictionary or otherwise provide a list of keywords as a database for example for use with Autocompletion software. (in Business and Productivity)

 
 

Things you can do from here:

 
 



--
重剑无锋,大巧不工。

Byte array <=> String in C# .Net

Byte myBytes1[]   =   myMemoryStream.ToArray();
String str   =   System.Text.Encoding.Default.GetString( myBytes1  );
Byte myBytes2[]=System.Text.Encoding.Default.GetBytes( str )   ;

Byte   myBytes1[]   =   myMemoryStream.ToArray   ();
String   str   =   (new   UnicodeEncoding()).GetString( myBytes1 );
Byte   myBytes2[]   =   (new   UnicodeEncoding()).GetBytes( str )   ;

Windows中的计时器(SetTimer和CreateWaitableTimer)

Windows中的计时器(SetTimer和CreateWaitableTimer)   
Timers (SetTimer and CreateWaitableTimer) in Windows
       
1.SetTimer
下面的例子创建了一个计时器(不与窗口相关联),该计时器过程函数建了20个消息框。
The following example creates a timer (that is not attached to a window) whose Timer Procedure creates 20 Message Boxes

#include <windows.h>

class foo_class {
  static int counter;
public:
  //static函数,相当于全局
  static void  __stdcall timer_proc(HWND,unsigned int, unsigned int, unsigned long) {
    if (counter++ < 20)
      MessageBox(0,"Hello","MessageBox",0);
    else
      PostQuitMessage(0);
  }
};

int foo_class::counter=0;

WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {

//第1个参数,MSDN中指出如果置为NULL,即0,不与窗口相关联。
//If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
//第2个参数会被忽略
//第3个参数,300毫秒触发一次
//第4个参数,触发时由函数foo_class::timer_proc响应
int iTimerID = SetTimer(0, 0, 300, foo_class::timer_proc);
  MSG m;
//这是消息循环
  while (GetMessage(&m,0,0,0)) {
    TranslateMessage(&m);
    DispatchMessage(&m);

   }
  return 1;
}

2.CreateWaitableTimer
这个例子演示如何在windows中使用计时器。
计时器被设计为(1)在第1次调用CreateWaitableTimer后2秒触发,(2)此后每3/4秒触发一次。
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <process.h>
#include <stdio.h>

unsigned __stdcall TF(void* arg) {
  HANDLE timer=(HANDLE) arg;

  while (1) {
    //此处,进程间通信的接收方
    //timer是命名的,因此进程间或线程间没有区别
    WaitForSingleObject(timer,INFINITE);
    printf(".");
  }

}

int main(int argc, char* argv[]) {
  //创建,命名为0,也可以是LPCTSTR,字符串
  //其他进程可以通过OpenWaitableTimer获得此timer的句柄,并对之进行SetWaitableTimer
  HANDLE timer = CreateWaitableTimer(
    0,
    false, // false=>will be automatically reset
    0);    // name

  LARGE_INTEGER li;

  const int unitsPerSecond=10*1000*1000; // 100 nano seconds

  // Set the event the first time 2 seconds
  // after calling SetWaitableTimer
  //2秒
  li.QuadPart=-(2*unitsPerSecond);
  //通过句柄设置timer
  SetWaitableTimer(
    timer,
    &li,
    750,   // Set the event every 750 milli Seconds
    0,
    0,
    false);
  //用TF函数启动worker线程
  _beginthreadex(0,0,TF,(void*) timer,0,0);

  // Wait forever,
  while (1) ;

  return 0;
}

参考:
1.[http://www.adp-gmbh.ch/win/misc/timer.html ]
2.[http://support.microsoft.com/kb/184796],中文的