import java.io.*;
class array
{
int i,temp,j;
array(int a[],int n)
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>=a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("elements in sorted order");
for(i=0;i<n;i++)
{
System.out.println(a[i]);
}
}
}
class parameterised_constructer_sortarray
{
public static void main(String args[])
{
int a[]=new int[10];
int i,n;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("enter the size of array");
n=Integer.parseInt(cin.readLine());
System.out.println("enter array element");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
array b=new array(a,n);
}
catch(Exception e){}
}
}
class array
{
int i,temp,j;
array(int a[],int n)
{
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>=a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.println("elements in sorted order");
for(i=0;i<n;i++)
{
System.out.println(a[i]);
}
}
}
class parameterised_constructer_sortarray
{
public static void main(String args[])
{
int a[]=new int[10];
int i,n;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("enter the size of array");
n=Integer.parseInt(cin.readLine());
System.out.println("enter array element");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
array b=new array(a,n);
}
catch(Exception e){}
}
}
No comments:
Post a Comment