Python 68
[Python 100] Python 100
n m m m
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
n = int(raw_input(' n :\n'))
m = int(raw_input(' m :\n'))
def move(array,n,m):
array_end = array[n - 1]
for i in range(n - 1,-1,- 1):
array[i] = array[i - 1]
array[0] = array_end
m -= 1
if m > 0:move(array,n,m)
number = []
for i in range(n):
number.append(int(raw_input(':\n')))
print ':',number
move(number,n,m)
print ':',number
n : 8 m : 5 : 2 : 8 : 6 : 1 : 78 : 45 : 34 : 2 : [2, 8, 6, 1, 78, 45, 34, 2] : [1, 78, 45, 34, 2, 2, 8, 6]
[Python 100] Python 100
kui
che***[email protected]
7 3 3 3
#!/usr/bin/python # -*- coding: UTF-8 -*- m = 3 a = [1,2,3,4,5,6,7] def rot(a,n): l = len(a) n = l-n return a[n:l]+a[0:n] b = rot(a,m) print a print bkui
che***[email protected]
252***[email protected]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- a = [1, 2, 3, 4, 5] # m = 3 # 3 for _ in range(m): a.insert(0, a.pop()) print(a)252***[email protected]
253***[email protected]
# coding:utf-8 n=int(input("1~n:")) List=[] for i in range(1,n+1): List.append(i) print("1~n:",List) print() m=int(input(":")) List2=List[n-m:n+1]+List[0:n-m] print(":",List2)253***[email protected]
helloworld
hol***[email protected]
helloworld
hol***[email protected]
CosmosHua
cos***[email protected]
Python3
def rLoop(ls, m): n = len(ls) return ls[n-m:n]+ls[0:n-m] ls = [i for i in range(1, 10)] print(rLoop(ls, 3)) #result: [7, 8, 9, 1, 2, 3, 4, 5, 6]CosmosHua
cos***[email protected]
sssss
lij***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- # 9 n=[1,2,3,4,5,6,7,8,9] # 5 m = 5 c=[] for i in range(len(n)): if i<(len(n)-m): c.append(n[i]) for i in c: n.remove(i) n.extend(c) print(n)sssss
lij***[email protected]
r49***[email protected]
#coding=utf-8 a=[] n=input('') for i in range(1,n+1): s=input('%d'%i) a.append(s) m=input('') print '%s'%a b=a[-m:] #m c=a[:-m] #m a=b+c # print '%s'%ar49***[email protected]
382***[email protected]
#coding:utf-8 # a=[] b=[] n=int(input("" )) m=int(input("" )) for i in range(n): a.append(int(input(" %d " %(i+1)))) b.extend(a*2) print(a) print(b[len(a)-m:2*len(a)-m])382***[email protected]
iMax4ever
jia***@foxmail.com
Python3:
#coding:utf-8 n = int(input(' n :')) m = int(input(' m :')) L = [] for i in range(n): print('{}:'.format(i+1), end='') L.append(int(input(''))) print('', L) print('', L[n-m:] + L[:n-m])iMax4ever
jia***@foxmail.com
944***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- c = [2, 8, 6, 1, 78, 45, 34, 2] for x in range(3): c.append(c.pop(0)) print c944***[email protected]
ng
409***[email protected]
python3
# -*- coding:UTF-8 -*- a=[2, 8, 6, 1, 78, 45, 34, 2] print(a) m=int(input('m')) if(m>=len(a)): print('error') for i in range(m): a.insert(0,a.pop()) print(a)ng
409***[email protected]