Cita:Código:sudo apt-get install python3-pip
Cita:Código:pip3 install --user roman
Cita:alias a2r="~/.local/bin/roman"
alias r2a="~/.local/bin/roman -r"
Cita:cd ~/.local/bin
Cita:$ ./roman -r XXX
$ ./roman 30
' Gambas class file
HBox1 As HBox
HBox2 As HBox
TextBoxArabIn As TextBox
Label1 As Label
Label2 As Label
LabelRomanOut As Label
sThous As String[] = ["", "M", "MM", "MMM", "MMMM", "MMMMM", "MMMMMM", "MMMMMMM", "MMMMMMMM", "MMMMMMMMM"]
sHuns As String[] = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]
sTens As String[] = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]
sNumerals As String[] = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
sAll As String[][] = [[""], sThous, sHuns, sTens, sNumerals]
Public Sub TextBoxArabIn_Change()
Dim sText As String = Trim(TextBoxArabIn.Text)
Dim sCheck As String = "0123456789"
Dim iLoop, iCount As Integer
Dim sWork As New String[]
If Len(sText) > 4 Then sText = Mid(sText, 1, 4)
sWork.Add("")
LabelRomanOut.Text = ""
For iLoop = 0 To Len(sText) - 1
If InStr(sCheck, sText[iLoop]) > 0 Then sWork.Add(sText[iLoop])
Next
iCount = 5 - sWork.Max
For iLoop = 1 To sWork.Max
LabelRomanOut.Text &= sAll[iCount][Val(sWork[iLoop])]
Inc iCount
Next
TextBoxArabIn.Text = Mid(sWork.Join(""), 1)
End
Public Sub Form_Open()
With Me
.H = 65
.W = 460
.Arrangement = Arrange.Vertical
.Padding = 5
End With
With HBox1 = New HBox(Me)
.H = 28
End With
With HBox2 = New HBox(Me)
.H = 28
.Invert = True
End With
With TextBoxArabIn = New TextBox(HBox1) As "TextBoxArabIn"
.H = 28
.W = 80
.Alignment = Align.Right
End With
With Label1 = New Label(HBox1)
.H = 28
.W = 35
.Alignment = Align.Center
.Text = " = "
End With
With LabelRomanOut = New Label(HBox1) As "LabelRomanOut"
.H = 28
.Border = Border.Plain
.Expand = True
.Font = Font["freeserif,12,bold"]
End With
With Label2 = New Label(HBox2)
.H = 28
.AutoResize = True
.Alignment = Align.BottomRight
.Text = "Charlie Ogier Software"
End With
End
' Gambas class file
HBox1 As HBox
HBox2 As HBox
HBox3 As HBox
TextBoxArabIn As TextBox
TextBoxRomanIn As TextBox
Label1 As Label
Label2 As Label
Label3 As Label
LabelRomanOut As Label
LabelArabOut As Label
Panel1 As Panel
sThous As String[] = ["", "M", "MM", "MMM", "MMMM", "MMMMM", "MMMMMM", "MMMMMMM", "MMMMMMMM", "MMMMMMMMM"]
sHuns As String[] = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"]
sTens As String[] = ["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"]
sNumerals As String[] = ["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"]
sAll As String[][] = [[""], sThous, sHuns, sTens, sNumerals]
Public Sub TextBoxArabIn_Change()
Dim sText As String = Trim(TextBoxArabIn.Text)
Dim iLoop, iCount As Integer
Dim sWork As New String[]
If Len(sText) > 4 Then sText = Mid(sText, 1, 4)
sWork.Add("")
LabelRomanOut.Text = ""
For iLoop = 0 To Len(sText) - 1
If InStr("0123456789", sText[iLoop]) > 0 Then sWork.Add(sText[iLoop])
Next
iCount = 5 - sWork.Max
For iLoop = 1 To sWork.Max
LabelRomanOut.Text &= sAll[iCount][Val(sWork[iLoop])]
Inc iCount
Next
TextBoxArabIn.Text = Mid(sWork.Join(""), 1)
TextBoxRomanIn.Text = LabelRomanOut.Text
End
Public Sub TextBoxRomanIn_Change()
Dim sOrder As String[] = ["M", "D", "C", "L", "X", "V", "I"]
Dim iOrder As Integer[] = [1000, 500, 100, 50, 10, 5, 1]
Dim sLess As String[] = ["CM", "CD", "XC", "XL", "IX", "IV"]
Dim iLess As Integer[] = [900, 400, 90, 40, 9, 4]
Dim sText As String = Trim(UCase(TextBoxRomanIn.Text))
Dim iLoop, iTotal As Integer
Dim iPos As Integer
Dim sHold, sVal As String
For iLoop = 0 To Len(sText) - 1
If InStr("MDCLXVI", sText[iLoop]) > 0 Then sHold &= sText[iLoop]
Next
sText = sHold
For iLoop = 0 To sLess.Max
iPos = InStr(sHold, sLess[iLoop])
If iPos > 0 Then
sVal = Mid(sHold, iPos, 2)
iTotal += iLess[sLess.Find(sVal)]
sHold = Replace(sHold, sVal, "")
End If
Next
For iLoop = 0 To Len(sHold) - 1
iTotal += iOrder[sOrder.Find(sHold[iLoop])]
Next
LabelArabOut.Text = Str(iTotal)
TextBoxRomanIn.Text = sText
TextBoxArabIn.Text = LabelArabOut.Text
End
Public Sub Form_Open()
With Me
.H = 100
.W = 460
.Arrangement = Arrange.Vertical
.Padding = 5
.Title = "V=5"
End With
HBox1 = New HBox(Me)
HBox1.H = 28
With TextBoxArabIn = New TextBox(HBox1) As "TextBoxArabIn"
.H = 28
.W = 80
.Alignment = Align.Right
End With
With Label1 = New Label(HBox1)
.H = 28
.W = 35
.Alignment = Align.Center
.Text = " = "
End With
With LabelRomanOut = New Label(HBox1) As "LabelRomanOut"
.H = 28
.Border = Border.Plain
.Expand = True
.Font = Font["freeserif,12,bold"]
End With
Panel1 = New Panel(Me)
Panel1.H = 7
HBox3 = New HBox(Me)
HBox3.H = 28
With TextBoxRomanIn = New TextBox(HBox3) As "TextBoxRomanIn"
.H = 28
.Expand = True
.Font = Font["freeserif,12,bold"]
End With
With Label3 = New Label(HBox3)
.H = 28
.W = 35
.Alignment = Align.Center
.Text = " = "
End With
With LabelArabOut = New Label(HBox3) As "LabelArabOut"
.H = 28
.W = 80
.Border = Border.Plain
.Alignment = Align.Right
End With
With HBox2 = New HBox(Me)
.H = 28
.Invert = True
End With
With Label2 = New Label(HBox2)
.H = 28
.AutoResize = True
.Alignment = Align.BottomRight
.Text = "Charlie Ogier Software V1.0.0"
End With
End
Cita:
- Public Sub Form_Open()
- With Me
- .H = 100
- .W = 460
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .Title = "V=5"
- End With
- HBox1 = New HBox(Me)
- HBox1.H = 28
- With TextBoxArabIn = New TextBox(HBox1) As "TextBoxArabIn"
- .H = 28
- .W = 80
- .Alignment = Align.Right
- End With
- With Label1 = New Label(HBox1)
- .H = 28
- .W = 35
- .Alignment = Align.Center
- .Text = " = "
- End With
- With LabelRomanOut = New Label(HBox1) As "LabelRomanOut"
- .H = 28
- .Border = Border.Plain
- .Expand = True
- .Font = Font["freeserif,12,bold"]
- End With
- Panel1 = New Panel(Me)
- Panel1.H = 7
- HBox3 = New HBox(Me)
- HBox3.H = 28
- With TextBoxRomanIn = New TextBox(HBox3) As "TextBoxRomanIn"
- .H = 28
- .Expand = True
- .Font = Font["freeserif,12,bold"]
- End With
- With Label3 = New Label(HBox3)
- .H = 28
- .W = 35
- .Alignment = Align.Center
- .Text = " = "
- End With
- With LabelArabOut = New Label(HBox3) As "LabelArabOut"
- .H = 28
- .W = 80
- .Border = Border.Plain
- .Alignment = Align.Right
- End With
- With HBox2 = New HBox(Me)
- .H = 28
- .Invert = True
- End With
- With Label2 = New Label(HBox2)
- .H = 28
- .AutoResize = True
- .Alignment = Align.BottomRight
- .Text = "Charlie Ogier Software V1.0.0"
- End With
- End