Microsoft QBasic 1.0 DIM n AS INTEGER CLS INPUT "n=", n REDIM a(1 TO n) AS INTEGER RANDOMIZE TIMER imax = 1 FOR i = 1 TO n a(i) = INT(30 * RND) IF a(i) > a(imax) THEN imax = i PRINT a(i); NEXT PRINT t = a(imax) FOR i = imax - 1 TO 1 STEP -1 a(i + 1) = a(i) NEXT a(1) = t FOR i = 1 TO n PRINT a(i); NEXT
DIM n AS INTEGER
CLS
INPUT "n=", n
REDIM a(1 TO n) AS INTEGER
RANDOMIZE TIMER
imax = 1
FOR i = 1 TO n
a(i) = INT(30 * RND)
IF a(i) > a(imax) THEN imax = i
PRINT a(i);
NEXT
PRINT
t = a(imax)
FOR i = imax - 1 TO 1 STEP -1
a(i + 1) = a(i)
NEXT
a(1) = t
FOR i = 1 TO n
PRINT a(i);
NEXT
Пример
n=15
5 16 10 18 11 12 10 26 27 22 20 5 16 18 4
27 5 16 10 18 11 12 10 26 22 20 5 16 18 4