PYTHON PROGRAM
n=int(input("Enter array size:"))
a=[]
print("Enter",n,"elements in array:")
for i in range (0,n):
s=int(input())
a.append(s)
for i in range (0,n-1):
flag=0
for j in range(0,(n-i)-1):
if(a[j]>a[j+1]):
t=a[j]
a[j]=a[j+1]
a[j+1]=t
flag=1
if(flag==0):
break
print("Elements in array after sorting:")
for i in range (0,n):
print(a[i])
No comments:
Post a Comment
let me know which type examples you want to comment me.