Given an array S of n integers, are there elements x, y, z in S such that x + y + z = 0? Find all unique triplets in the array which gives the sum of zero.

Note:

• Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
• The solution set must not contain duplicate triplets.

一个重要的优化就是如果上个数已经求过集合了 例如[-1 -1 0 2 2]已经包含了[-1 0 2 2] 当然也包含了 [-1 0 2]集合的。

posted @ 2012-12-10 11:38 micheal's tech 阅读(187) | 评论 (0)编辑 收藏

`#include <thread>template <typename Duration, typename Function>void timer(Duration const & d, Function const & f){    std::thread([d,f](){        std::this_thread::sleep_for(d);        f();    }).detach();}`

posted @ 2012-12-04 18:10 micheal's tech 阅读(1090) | 评论 (0)编辑 收藏

This problem is caused when including `<windows.h>` before `<winsock2.h>`. Try arrange your include list that `<windows.h>` is included after `<winsock2.h>` or define `_WINSOCKAPI_` first:

posted @ 2012-12-04 15:39 micheal's tech 阅读(1281) | 评论 (0)编辑 收藏

`普通类调用中必须吧zmq设置为指针 否则单纯构造无法初始化直接用初始化列表context(1),netsocket(zmq::socket_t(context, ZMQ_REP))`

posted @ 2012-12-03 17:51 micheal's tech 阅读(354) | 评论 (0)编辑 收藏

posted @ 2012-11-14 10:17 micheal's tech 阅读(555) | 评论 (0)编辑 收藏

## 感觉动态规划中最难的部分是在寻找 从状态j到状态i的递归式，就像证明归纳法一样，你得找出具体的式子来。top bottombottom up1. Longest Increasing Subsequence:L[i] = max(1+L(j))(j<l && a[j]<a[i])//if not exist any a[j]<a[i]L[i] = 1;getmaxvalueof array a[]2. Maximum Sum Increasing Subsequencealmost same with above3. Maximum continous sum4. rod cutting

posted @ 2012-05-17 09:54 micheal's tech 阅读(409) | 评论 (0)编辑 收藏

posted @ 2012-04-17 08:40 micheal's tech 阅读(373) | 评论 (1)编辑 收藏

posted @ 2012-04-12 13:56 micheal's tech 阅读(259) | 评论 (0)编辑 收藏

VS 2008 uninstall package.

posted @ 2009-12-01 17:20 micheal's tech 阅读(291) | 评论 (0)编辑 收藏

# How can I run another application or batch file from my Visual C# .NET code?

Published 01 June 04 11:54 PM

Posted by: Duncan Mackenzie, MSDN
This post applies to Visual C# .NET 2002/2003

Suppose you want to run a command line application, open up another Windows program, or even bring up the default web browser or email program... how can you do this from your C# code?

The answer for all of these examples is the same, you can use the classes and methods in System.Diagnostics.Process to accomplish these tasks and more.

Example 1. Running a command line application, without concern for the results:

`private void simpleRun_Click(object sender, System.EventArgs e){ System.Diagnostics.Process.Start(@"C:\listfiles.bat");}`

Example 2. Retrieving the results and waiting until the process stops (running the process synchronously):

`private void runSyncAndGetResults_Click(object sender, System.EventArgs e){ System.Diagnostics.ProcessStartInfo psi =   new System.Diagnostics.ProcessStartInfo(@"C:\listfiles.bat"); psi.RedirectStandardOutput = true; psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; psi.UseShellExecute = false; System.Diagnostics.Process listFiles; listFiles = System.Diagnostics.Process.Start(psi); System.IO.StreamReader myOutput = listFiles.StandardOutput; listFiles.WaitForExit(2000); if (listFiles.HasExited)  {  string output = myOutput.ReadToEnd();  this.processResults.Text = output; }}`

Example 3. Displaying a URL using the default browser on the user's machine:

`private void launchURL_Click(object sender, System.EventArgs e){ string targetURL = @http://www.duncanmackenzie.net; System.Diagnostics.Process.Start(targetURL);}`

In my opinion, you are much better off following the third example for URLs, as opposed to executing IE with the URL as an argument. The code shown for Example 3 will launch the user's default browser, which may or may not be IE; you are more likely to provide the user with the experience they want and you will be taking advantage of the browser that is most likely to have up-to-date connection information.