INPUT "vvedite stroku ", a$
INPUT "vvedite kol-vo slov ", n
FOR i = 1 TO LEN(a$)
IF MID$(a$, i, 1) = " " THEN k = k + 1
IF k = n - 1 THEN b$ = MID$(a$, i + 1) + " " + LEFT$(a$, i)
NEXT
PRINT "novaya stroka:"
PRINT b$
Следующий вариант
INPUT "vvedite stroku ", a$
FOR i = 1 TO LEN(a$)
IF MID$(a$, i, 1) = " " THEN m = m + 1
NEXT
INPUT "vvedite kol-vo slov ", n
IF n > (m + 1) THEN n = n MOD (m + 1)
FOR i = 1 TO LEN(a$)
IF MID$(a$, i, 1) = " " THEN k = k + 1
IF k = n - 1 THEN b$ = MID$(a$, i + 1) + " " + LEFT$(a$, i)
NEXT
PRINT "novaya stroka:"
PRINT b$
Тестирование выполнено в программе QB64 ( Скачать )