I 'll get the 9, because the continuous line to satisfy the conditions, must be continuous, not short in the middle,
If you have a better way, can add my Qq: 68345106, this way can I pay cost,
CodePudding user response:
IEnumerableSeq (& lt; List Data, n)
{
for (int i=0; iYield return data. The Skip (I) Take (n);
}
Void Main ()
{
ListData=https://bbs.csdn.net/topics/{" 23456 ", "57876", "63465",... };
String cond="2-5-6-2-5-6-4".
Var query=seq (data, cond. Split (' - '). The Count () + 1)
The Where (x=& gt; X.T ake (x.C mount () - 1). The Zip (cond. Split (' - '), (a, b)=& gt; A.S tartsWith). (b) All ())
The Select (x=& gt; X.L ast ());
The foreach (var item in the query)
Console. WriteLine (item);
}
CodePudding user response:
Why don't knot post, one's fingers itch to write down, vb codeSub Main ()
For I=0 To 4
Console. WriteLine (" input filter number: ")
Dim MatchS=Console. ReadLine
Dim RLT=MatchNumber (MatchS)
If Not RLT Is Nothing Then RLT. ForEach (Sub (t) Console. WriteLine (t))
Next
The Console. The Read ()
End Sub
The Function MatchNumber (MatchS the As String) As the List (Of String)
Dim sList=MatchS. ToList
Dim TB=(New testDataDataContext). TpTest
Dim datalist=TB. Select (Function (Dr) New With {Key. Id=Dr. Id, the s1=Dr. ValueS. The Substring (0, 1)}), Where (Function (r) r.s 1 Equals (sList. First))
Dim OutTxt=New List (Of String)
The datalist. ToList. ForEach (Sub (Dr)
Dim MatchData=https://bbs.csdn.net/topics/tb.Where (Function (r)>=Dr. R.i d id), Select (Function (x) New With {Key. Id=x.i d,. S1=x.V alueS. Substring (0, 1)}), Take (sList. Count)
Dim CompareS=String. Join (" ", MatchData. Select (Function (r) r.s 1))
If CompareS. Equals (MatchS) Then
Dim curMaxId=MatchData. Max (Function (r) r.i d)
Dim rltDataRow=TB. The Where (Function (d) d.i d & gt; CurMaxId.) Take (1)
OutTxt. Add (rltDataRow. Select (Function (r) r.V alueS). The ToArray (0))
End the If
End Sub)
If OutTxt. Count & gt; 0 Then
Return OutTxt
The Else
Return Nothing
End the If
End the Function
CodePudding user response: