Problem
Defines a one-dimensional array of type int, containing 10 elements, each assigned a value of 1~10, and then moving the elements in the array forward one position.
That is, a[0]=a[1],a[1]=a[2],... The value of the last element is the value of the original first element, and then the array is output.
Resolution (Python)
#!/usr/bin/env python#coding:utf-8def Ahead_one (): a = [I for I in range] B = A.pop (0) a.append (b) return AIF __name__ = = "__main__": print Ahead_one ()
Settlement (Racket 5.2.1)
#lang racket; define function Ahead-one; Enter as an integer list int-list, assuming its length is N; The output is the same length as the integer list, whose nth-bit element is the 1th-bit element of int-list; The element of its 1~n-1 bit is the element of Int-list's 2~n bit (define (Ahead-one int-list) (Append (rest int-list) (list (first int-list))); function call, normal operation should output ' (2 3 4 5 6 7 8 9, 1) (Ahead-one (List 1 2 3 4 5 6 7 8 9 10))