السلام عليكم
لوسمحتم يا اخوان انا محتاج هالكود ضروري بس بصراحه انا ماعرف حق فجوال بيسك ممكن احد يتفضل ويعطف علي ويحوب هالكود الى اللغات اي من اللغات التاليه وشكرا
جافا او c/c++ او باسكال
ويفضل بالجافا اتمنى من اهل البيسك يساعدوني ولله محتاجه ضروري
Const cBlockCount As Integer = 13 Dim arrGrid() As Integer Dim gridSize As Integer Dim i As Integer, j As Integer Dim k As Integer Private Type block x As Integer y As Integer End Type Dim arrPiece(1 To cBlockCount, 1 To 4) As block Private Sub cmdStartTest_Click() 'Read file (tetris.in) Dim lines() As String lines() = Split(ReadTextFileContents(App.Path & "\tetris.in"), vbCrLf) 'Get grid size If lines(0) < 4 Or lines(0) > 100 Then MsgBox "Grid must be 4 <= N <= 100.", vbExclamation Exit Sub End If gridSize = lines(0) 'ReDim array for Grid ReDim arrGrid(1 To gridSize, 1 To gridSize) As Integer 'Load numbers into grid On Error GoTo errGrid For j = 1 To gridSize For i = 1 To gridSize arrGrid(i, j) = Mid$(lines(j), 2 * (i - 1) + (i - 1) + 1, 2) Next Next 'Set Tetris pieces 'OOOO arrPiece(1, 1).x = 1 arrPiece(1, 1).y = 1 arrPiece(1, 2).x = 1 arrPiece(1, 2).y = 2 arrPiece(1, 3).x = 1 arrPiece(1, 3).y = 3 arrPiece(1, 4).x = 1 arrPiece(1, 4).y = 4 'O 'O 'O 'O arrPiece(2, 1).x = 1 arrPiece(2, 1).y = 1 arrPiece(2, 2).x = 2 arrPiece(2, 2).y = 1 arrPiece(2, 3).x = 3 arrPiece(2, 3).y = 1 arrPiece(2, 4).x = 4 arrPiece(2, 4).y = 1 'OO ' OO arrPiece(3, 1).x = 1 arrPiece(3, 1).y = 1 arrPiece(3, 2).x = 1 arrPiece(3, 2).y = 2 arrPiece(3, 3).x = 2 arrPiece(3, 3).y = 2 arrPiece(3, 4).x = 2 arrPiece(3, 4).y = 3 ' O 'OO 'O arrPiece(4, 1).x = 1 arrPiece(4, 1).y = 2 arrPiece(4, 2).x = 2 arrPiece(4, 2).y = 2 arrPiece(4, 3).x = 2 arrPiece(4, 3).y = 1 arrPiece(4, 4).x = 3 arrPiece(4, 4).y = 1 'OOO ' O arrPiece(5, 1).x = 1 arrPiece(5, 1).y = 1 arrPiece(5, 2).x = 1 arrPiece(5, 2).y = 2 arrPiece(5, 3).x = 1 arrPiece(5, 3).y = 3 arrPiece(5, 4).x = 2 arrPiece(5, 4).y = 3 ' O ' O 'OO arrPiece(6, 1).x = 1 arrPiece(6, 1).y = 2 arrPiece(6, 2).x = 2 arrPiece(6, 2).y = 2 arrPiece(6, 3).x = 3 arrPiece(6, 3).y = 2 arrPiece(6, 4).x = 3 arrPiece(6, 4).y = 1 'O 'OOO arrPiece(7, 1).x = 1 arrPiece(7, 1).y = 1 arrPiece(7, 2).x = 2 arrPiece(7, 2).y = 1 arrPiece(7, 3).x = 2 arrPiece(7, 3).y = 2 arrPiece(7, 4).x = 2 arrPiece(7, 4).y = 3 'OO 'O 'O arrPiece(8, 1).x = 1 arrPiece(8, 1).y = 1 arrPiece(8, 2).x = 1 arrPiece(8, 2).y = 2 arrPiece(8, 3).x = 2 arrPiece(8, 3).y = 1 arrPiece(8, 4).x = 3 arrPiece(8, 4).y = 1 'OOO ' O arrPiece(9, 1).x = 1 arrPiece(9, 1).y = 1 arrPiece(9, 2).x = 1 arrPiece(9, 2).y = 2 arrPiece(9, 3).x = 1 arrPiece(9, 3).y = 3 arrPiece(9, 4).x = 2 arrPiece(9, 4).y = 2 ' O 'OO ' O arrPiece(10, 1).x = 1 arrPiece(10, 1).y = 2 arrPiece(10, 2).x = 2 arrPiece(10, 2).y = 1 arrPiece(10, 3).x = 2 arrPiece(10, 3).y = 2 arrPiece(10, 4).x = 3 arrPiece(10, 4).y = 2 ' O 'OOO arrPiece(11, 1).x = 1 arrPiece(11, 1).y = 2 arrPiece(11, 2).x = 2 arrPiece(11, 2).y = 1 arrPiece(11, 3).x = 2 arrPiece(11, 3).y = 2 arrPiece(11, 4).x = 2 arrPiece(11, 4).y = 3 'O 'OO 'O arrPiece(12, 1).x = 1 arrPiece(12, 1).y = 1 arrPiece(12, 2).x = 2 arrPiece(12, 2).y = 1 arrPiece(12, 3).x = 2 arrPiece(12, 3).y = 2 arrPiece(12, 4).x = 3 arrPiece(12, 4).y = 1 'OO 'OO arrPiece(13, 1).x = 1 arrPiece(13, 1).y = 1 arrPiece(13, 2).x = 1 arrPiece(13, 2).y = 2 arrPiece(13, 3).x = 2 arrPiece(13, 3).y = 1 arrPiece(13, 4).x = 2 arrPiece(13, 4).y = 2 'Start test cases Dim mCnt As Integer Dim mSum As Long Dim mLargestCase As Integer Dim mLargest As Long mCnt = 0 mLargest = 0 For k = 1 To cBlockCount For j = 1 To gridSize For i = 1 To gridSize If arrPiece(k, 1).x + (i - 1) <= gridSize And arrPiece(k, 1).y + (j - 1) <= gridSize And arrPiece(k, 2).x + (i - 1) <= gridSize And arrPiece(k, 2).y + (j - 1) <= gridSize And arrPiece(k, 3).x + (i - 1) <= gridSize And arrPiece(k, 3).y + (j - 1) <= gridSize And arrPiece(k, 4).x + (i - 1) <= gridSize And arrPiece(k, 4).y + (j - 1) <= gridSize Then mSum = arrGrid(arrPiece(k, 1).x + (i - 1), arrPiece(k, 1).y + (j - 1)) mSum = mSum + arrGrid(arrPiece(k, 2).x + (i - 1), arrPiece(k, 2).y + (j - 1)) mSum = mSum + arrGrid(arrPiece(k, 3).x + (i - 1), arrPiece(k, 3).y + (j - 1)) mSum = mSum + arrGrid(arrPiece(k, 4).x + (i - 1), arrPiece(k, 4).y + (j - 1)) mCnt = mCnt + 1 'Get largest sum If mSum > mLargest Then mLargest = mSum mLargestCase = mCnt End If 'Write result to textbox txtResult.Text = txtResult.Text & mCnt & "." & vbTab & mSum & vbCrLf End If Next Next Next 'Display summary result Me.lblResult.Caption = "No Of Ways: " & mCnt & vbCrLf & "Largest Case: " & mLargestCase & vbCrLf & "Largest Sum: " & mLargest '**Output for your answer Me.lblOutput.Caption = mLargestCase & ". " & mLargest Exit Sub errGrid: MsgBox "Please check your grid.", vbExclamation End Sub Function ReadTextFileContents(filename As String) As String Dim fnum As Integer, isOpen As Boolean On Error GoTo Error_Handler fnum = FreeFile() Open filename For Input As #fnum isOpen = True ReadTextFileContents = Input(LOF(fnum), fnum) Error_Handler: If isOpen Then Close #fnum If Err Then MsgBox Err.Number & ": " & Err.Description End Function