The four number declare before a program
CODING:
class sort1{
public static void main(String ar[]){
int a=2,b=4,c=3,d=1,temp;
if(a>b){temp=a;a=b;b=temp;}
if(c>d){temp=c;c=d;d=temp;}
if(a>c){temp=a;a=c;c=temp;}
if(b>d){temp=b;b=d;d=temp;}
if(b>c){temp=b;b=c;c=temp;}
System.out.print(a+" "+b+" "+c+" "+d);
}
}
public static void main(String ar[]){
int a=2,b=4,c=3,d=1,temp;
if(a>b){temp=a;a=b;b=temp;}
if(c>d){temp=c;c=d;d=temp;}
if(a>c){temp=a;a=c;c=temp;}
if(b>d){temp=b;b=d;d=temp;}
if(b>c){temp=b;b=c;c=temp;}
System.out.print(a+" "+b+" "+c+" "+d);
}
}
Comments
Post a Comment