Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
53
Task/Spiral-matrix/Ring/spiral-matrix.ring
Normal file
53
Task/Spiral-matrix/Ring/spiral-matrix.ring
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Project : Spiral matrix
|
||||
|
||||
load "guilib.ring"
|
||||
load "stdlib.ring"
|
||||
new qapp
|
||||
{
|
||||
win1 = new qwidget() {
|
||||
setwindowtitle("Spiral matrix")
|
||||
setgeometry(100,100,600,400)
|
||||
n = 5
|
||||
result = newlist(n,n)
|
||||
spiral = newlist(n,n)
|
||||
k = 1
|
||||
top = 1
|
||||
bottom = n
|
||||
left = 1
|
||||
right = n
|
||||
while (k <= n*n)
|
||||
for i= left to right
|
||||
result[top][i] = k
|
||||
k = k + 1
|
||||
next
|
||||
top = top + 1
|
||||
for i = top to bottom
|
||||
result[i][right] = k
|
||||
k = k + 1
|
||||
next
|
||||
right = right - 1
|
||||
for i = right to left step -1
|
||||
result[bottom][i] = k
|
||||
k = k + 1
|
||||
next
|
||||
bottom = bottom - 1
|
||||
for i = bottom to top step -1
|
||||
result[i][left] = k
|
||||
k = k + 1
|
||||
next
|
||||
left = left + 1
|
||||
end
|
||||
for m = 1 to n
|
||||
for p = 1 to n
|
||||
spiral[p][m] = new qpushbutton(win1) {
|
||||
x = 150+m*40
|
||||
y = 30 + p*40
|
||||
setgeometry(x,y,40,40)
|
||||
settext(string(result[m][p]))
|
||||
}
|
||||
next
|
||||
next
|
||||
show()
|
||||
}
|
||||
exec()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue