import java.util.*;
class Array2
{
public static void main(String[] args)
{
int array1[]=new int[100];
int i,j,n;
Scanner sc=new Scanner(System.in);
System.out.print("\n\n\t\tEnter The Size Of Array===> ");
n=sc.nextInt();
System.out.println("\n\n\t\tEnter The "+n+" Element Of Array");
for(i=0;i<=n;i++)
{
array1[i]=sc.nextInt();
}
System.out.println("\n\n\t\tElements in Array Before Sorting===>");
for(i=0;i<=n;i++)
{
System.out.print("\n\t\tArray"+i+"="+array1[i]);
}
System.out.println("\n\n\t\tElements in Array After Sorting===>");
for(i=0;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(array1[i]>array1[j]){
int temp=array1[i];
array1[i]=array1[j];
array1[j]=temp;}
}
System.out.print("\n\t\tArray"+i+"="+array1[i]);
}
}
}
class Array2
{
public static void main(String[] args)
{
int array1[]=new int[100];
int i,j,n;
Scanner sc=new Scanner(System.in);
System.out.print("\n\n\t\tEnter The Size Of Array===> ");
n=sc.nextInt();
System.out.println("\n\n\t\tEnter The "+n+" Element Of Array");
for(i=0;i<=n;i++)
{
array1[i]=sc.nextInt();
}
System.out.println("\n\n\t\tElements in Array Before Sorting===>");
for(i=0;i<=n;i++)
{
System.out.print("\n\t\tArray"+i+"="+array1[i]);
}
System.out.println("\n\n\t\tElements in Array After Sorting===>");
for(i=0;i<=n;i++)
{
for(j=i+1;j<=n;j++)
{
if(array1[i]>array1[j]){
int temp=array1[i];
array1[i]=array1[j];
array1[j]=temp;}
}
System.out.print("\n\t\tArray"+i+"="+array1[i]);
}
}
}
No comments:
Post a Comment