In a given sequence of numbers, count the number of pairs (consecutive numbers), represented by positive values, and the number of pairs, the values of whose elements have the opposite sign. Display a message about the number of which pairs prevail.
local function main() print("Введите строку") p = 0 m = 0 str = io.read() a = string.len(str) for i = 1, a do if str:sub(i,i) == "+" and str:sub(i+3,i+3) == "+" then p=p+1 else if str:sub(i,i)== "-" and str:sub(i+3,i+3) == "-" then m = m+1 end end end if p > m then print("Положительная последовательность больше") else if m > p then print("Отрицательная последовательность больше") else print("Последовательности равны") end end end main() in such a sequence +3 + 4-5 -5-5, I compare the first character with the third and so on. but the problem is that there may be a two-digit number and then the program will not work correctly, how to get around this problem. match can help me? Well, to look for a space and compare with the sign after it? or something else is possible?