namereq

成績のソート(成績降順)

Jun 22nd, 2018
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. listA=[]
  2. for num in range(0,3):
  3.     a=int(input("学生番号"))
  4.     b=int(input("点数"))
  5.     lista=[a,b]
  6.     listA.append(lista)
  7.    
  8. for i in range(0,3):
  9.     for j in range(i+1,3):    
  10.         if listA[i][1] < listA[j][1]:
  11.             w=listA[i]
  12.             listA[i]=listA[j]
  13.             listA[j]=w
  14. print("sort後",listA)
Advertisement
Add Comment
Please, Sign In to add comment