Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removedec(number)
- kek = number
- local strnum = tostring(number)
- for i=1,#strnum do
- if string.sub(strnum,i,i) == "." and string.sub(strnum,i+1,i+1) == "0" and string.sub(strnum,i+2,i+2) == "" then
- kek = tonumber(string.sub(strnum,1,i-1))
- end
- end
- return kek
- end
- function calc(strin)
- if strin:sub(1,7):lower() == "x^2+y^2" then
- if strin:sub(8,8):lower() == "+" then
- neg1 = false
- else
- neg1 = true
- end
- for i=9,100 do
- if strin:sub(i,i):lower() == "x" then
- numx = string.sub(strin,9,i-1)
- currenti = i+1
- break
- end
- end
- if strin:sub(currenti,currenti):lower() == "+" then
- neg2 = false
- else
- neg2 = true
- end
- for i=currenti,200 do
- if strin:sub(i,i):lower() == "y" then
- numy = string.sub(strin,currenti+1,i-1)
- currenti = i+1
- break
- end
- end
- if strin:sub(currenti,currenti):lower() == "+" then
- neg3 = false
- else
- neg3 = true
- end
- for i=currenti,300 do
- if strin:sub(i,i):lower() == "=" then
- currenti2 = i
- numout = string.sub(strin,currenti+1,i-1)
- if string.sub(strin,currenti,currenti) == "+" then
- neg4 = false
- else
- neg4 = true
- end
- break
- end
- end
- ----
- nexnumber = string.sub(strin,currenti2)
- ----
- numx2 = removedec((tonumber(numx)/2)*(tonumber(numx)/2))
- numy2 = removedec((tonumber(numy)/2)*(tonumber(numy)/2))
- ----
- if neg1 == false then
- rea1 = "x² + "..numx.."x"
- rea2 = "x² + "..numx.."x"
- rea3 = "x² + "..numx.."x"
- rea4 = "x² + "..numx.."x + "..numx2
- rea5 = "(x + "..removedec((numx/2))..")²"
- else
- rea1 = "x² - "..numx.."x"
- rea2 = "x² - "..numx.."x"
- rea3 = "x² - "..numx.."x"
- rea4 = "x² - "..numx.."x + "..numx2
- rea5 = "(x - "..removedec(((numx/2)*1))..")²"
- end
- ----
- if neg2 == false then
- bea1 = "y² + "..numy.."y"
- bea2 = "y² + "..numy.."y"
- bea3 = "y² + "..numy.."y"
- bea4 = "y² + "..numy.."y + "..numy2
- bea5 = "(y + "..removedec((numy/2))..")²"
- else
- bea1 = "y² - "..numy.."y"
- bea2 = "y² - "..numy.."y"
- bea3 = "y² - "..numy.."y"
- bea4 = "y² - "..numy.."y + "..numy2
- bea5 = "(y - "..removedec(((numy/2)*1))..")²"
- end
- ----w
- if neg4 == false then
- rewrite = rea1.." + "..bea1.." + "..numout.." = 0"
- numout = tonumber(numout)
- else
- rewrite = rea1.." + "..bea1.." - "..numout.." = 0"
- numout = tonumber(numout)*-1
- end
- print(rewrite)
- rewrite2 = rea2.." + "..bea2.." = "..numout*-1
- print(rewrite2)
- rewrite3 = rea3.." + ___ + "..bea3.." + ___ = "..(numout*-1).." + ___ + ___"
- print(rewrite3)
- rewrite4 = rea4.." + "..bea4.." = "..(numout*-1).." + "..numx2.." + "..numy2
- print(rewrite4)
- rewrite5 = rea5.." + "..bea5.." = "..((numout*-1)+numx2+numy2)
- print(rewrite5)
- end
- end
- calc("x^2+y^2+4x-4y+0=0")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement