Search This Blog

Friday, August 12, 2011

Ascending order,Descending order program in python

Fellow Python developers,


Python has a sorted() or sort() function to implement ascending or descending order programs,but supposing if i want to develop a ascending order program that takes user input and ascends or descends them,how should I go about?


For Example: Lets Say i want to convert this C program to Python?


= File Edit Search Run Compile Debug Project Options Window Help

+-[�]------------------------------- J.CPP ------------------------------1-[?]-+

� ?

�# include

�# include

�void main() �

�{

int a[10],i,j,n,temp;

clrscr();

cout<<"nEnter n nos: ";

cin>>n;

cout<<"nEnter the numbers: ";

for(i=0;i
cin>>a[i];

for(i=0;i
for(j=i+1;j
{

if(a[i]>a[j])

{

temp=a[i];


a[i]=a[j];

a[j]=temp;

}

}

for(i=0;i
cout<
getch();

}


_________________________________

This is an ascending order program in C.


Thanks in Advance! �

http://bit.ly/ofw9R3

No comments:

Post a Comment