In C, using a rotating memory block (note, not something I'm proud of...):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_MAX 10
void rotate_array (int *array, int size) {
int tmp = array[size - 1];
memmove(array + 1, array, sizeof(int) * (size - 1));
array[0] = tmp;
}
int main (int argc, char **argv) {
int idx, max, tmp_array[MAX_MAX];
if (argc > 1) {
max = atoi(argv[1]);
if (max <= MAX_MAX) {
/* load the array */
for (idx = 0; idx < max; ++idx) {
tmp_array[idx] = idx + 1;
}
/* rotate, print, lather, rinse, repeat... */
for (idx = 0; idx < max; ++idx) {
rotate_array(tmp_array, max);
printf("%d ", tmp_array[0]);
}
printf("\n");
}
}
return 0;
}
And a common lisp solution treating lists as ints:
(defun foo (max)
(format t "~{~A~^ ~}~%"
(maplist (lambda (x) (length x)) (make-list max))))
Making this into an executable is probably the hardest part and is left as an exercise to the reader.