锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 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: Posted by: Duncan Mackenzie, MSDN 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: Example 2. Retrieving the results and waiting until the process stops (running the process synchronously): Example 3. Displaying a URL using the default browser on the user's machine: 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. C# code download available from http://www.duncanmackenzie.net/Samples/default.aspx By the way, this post is a simple port of an earlier VB FAQ post... just in case you thought you had seen it already in your feeds...
涓涓噸瑕佺殑浼樺寲灝辨槸濡傛灉涓婁釜鏁板凡緇忔眰榪囬泦鍚堜簡 渚嬪[-1 -1 0 2 2]宸茬粡鍖呭惈浜哰-1 0 2 2] 褰撶劧涔熷寘鍚簡 [-1 0 2]闆嗗悎鐨勩?/li>
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();
}<windows.h> before <winsock2.h>. Try arrange your include list that <windows.h> is included after <winsock2.h> or define _WINSOCKAPI_ first:
鍏堝寘鍚玾insock2.h
鍐嶅寘鍚玾indows.h
鐩存帴鐢ㄥ垵濮嬪寲鍒楄〃
bottom up
1. 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 Subsequence
almost same with above
3. Maximum continous sum
4. rod cutting
upgrade code.
This post applies to Visual C# .NET 2002/2003private void simpleRun_Click(object sender, System.EventArgs e){
System.Diagnostics.Process.Start(@"C:\listfiles.bat");
}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;
}
}private void launchURL_Click(object sender, System.EventArgs e){
string targetURL = @http://www.duncanmackenzie.net;
System.Diagnostics.Process.Start(targetURL);
}