標籤雲
2014年4月25日 星期五
Maze Sample
2014年4月22日 星期二
Resurive Sample
'' 求1+3+5+ + 99 = ?
'Public Class Form1
' Dim sumN = 0
' Sub sum(sN, eN, stepN)
' '判斷結束否
' If sN > eN Then Return
' '每次過程要做的事
' sumN = sumN + sN
' '往完成工作方向前進
' sum(sN + stepN, eN, stepN)
' End Sub
' Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Call sum(1, 100, 2)
' MsgBox(sumN)
' End Sub
'End Class
' 求1!+2!+3!+ + 10! = ?
'Public Class Form1
' Dim sumN = 0
' Sub sum(sN, eN, stepN)
' '判斷結束否
' If sN > eN Then Return
' '每次過程要做的事
' Dim tsum = 1
' For i = 1 To sN
' tsum = tsum * i
' Next
' sumN = sumN + tsum
' '往完成工作方向前進
' sum(sN + stepN, eN, stepN)
' End Sub
' Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Call sum(1, 5, 1)
' MsgBox(sumN)
' End Sub
'End Class
'尋找最大值
'Public Class Form1
' Dim maxValue = 0
' Dim a() = {10, 200, 100, 50, 30}
' Sub fMax(sN, eN)
' '判斷結束否
' If sN > eN Then Return
' '每次過程要做的事
' If a(sN) > maxValue Then maxValue = a(sN)
' '往完成工作方向前進
' fMax(sN + 1, eN)
' End Sub
' Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Call fMax(0, a.Length - 1)
' MsgBox(maxValue)
' End Sub
'End Class
重覆排列
2014年4月1日 星期二
Kill Process
'Kill process
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Interval = 5000
Timer1.Enabled = True
End Sub
Sub killProcess(processName)
Dim process1 As Process()
process1 = Process.GetProcessesByName(processName)
For Each proces As Process In process1
proces.Kill()
Next
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
System.Diagnostics.Process.Start("iexplore")
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Call killProcess("iexplore")
Call killProcess("mspaint")
End Sub
End Class
2013年7月17日 星期三
最長共同子序列
#include <iostream>
#include <string>
using namespace std;
#define LEN 1000
int table[LEN + 1][LEN + 1];
char seq1[LEN + 1], seq2[LEN + 1];
string cs="";
int lcs_length(int s1Len, int s2Len)
{
int i, j;
memset(table, 0, sizeof(table));
for(i = 1; i <= s1Len; ++i) {
for(j = 1; j <= s2Len; ++j) {
if(seq1[i - 1] == seq2[j - 1])
{
table[i][j] = table[i - 1][j - 1] + 1;
cs=cs + seq1[i - 1];
}
else
table[i][j] = max(table[i - 1][j],table[i][j - 1]);
}
}
return table[s1Len][s2Len];
}
int main()
{
while (cin >>seq1 >> seq2)
{
int s1Len = strlen(seq1), s2Len = strlen(seq2);
cout << lcs_length(s1Len, s2Len) << "--" << cs << endl;
}
return 0;
}



