fork(1) download
  1. def bsort(x):
  2. while(True):
  3. flg=0
  4. n=len(x)-2
  5. for i in range(n):
  6. if x[i]>x[i+1]:
  7. tmp=x[i]
  8. x[i]=x[i+1]
  9. x[i+1]=tmp
  10. flg=1
  11. if (flg==0):
  12. break
  13.  
  14. def search(x,a):
  15. n=len(x)-1
  16. for i in range(n):
  17. if x[i]>a:
  18. break
  19. if x[i]==a:
  20. print("x["+str(i)+"]="+str(a))
  21.  
  22.  
  23. z=[1,2,3,1,2,3,1,2,3]
  24. bsort(z)
  25. search(z,2)
  26.  
Success #stdin #stdout 0.02s 27656KB
stdin
Standard input is empty
stdout
x[3]=2
x[4]=2
x[5]=2