Dim As String s
Dim As Integer i, j
Input " enter string with odd no of characters:",s
For i = 0 to len(s)-1
For j = 0 to len(s) - 1
If i = j or i + j =len(s) - 1 then
Print chr(i), ' semicolon
Else
Print " ",
End if
Next j
Next i
Sleep
There will be a point of intersection ( if i = j)
But how to print the relevant character of the string. I tried
Converting between ascii values and char but it doesn't seem to work.
'Print string of odd length in ‘X’ format
'https://www.geeksforgeeks.org/print-string-of-odd-length-in-x-format/
'transllated to FB by srvaldez
Sub printPattern(Byval s As String, Byval length As Long)
' i and j are the indexes of characters
' to be displayed in the ith iteration
' i = 0 intially and go upto length of
' string
' j = length of string initially
' in each iteration of i, we increment
' i and decrement j, we print character
' only of k==i or k==j
Dim As Long j
For i As Long = 0 To length-1
j = length -1 - i
For k As Long = 0 To length-1
If k = i Or k = j Then
Print Chr(s[k]);
Else
Print " ";
End If
Next
Print
Next
End Sub
printPattern("ganache", Len("ganache"))