HUO Computer Tips and tricks

Welcome to My Website. This website about Computer, Mobile and internet Tips and tricks,free Softwares and many more...

Welcome to My website

اسلام علیکم میرےویب سائٹ میں آنے کا بہت بہت شکریہ آپ اس ویب سائٹ میں مختلف کمپیوٹر،موبائل اور انٹرنٹ ٹپس اور ٹرکس سیکھ سکتے ہیں۔۔ ﷽ اVisit my new Website www.courseshub.org for free couses and other educational stuff

Monday 12 March 2018

import java.util.*;

public class Main
{
static int sl(int a[]){
for(int i=0;i<a.length-1;i++)
for(int j=0;j<a.length-i-1;j++)
   if(a[j]<a[j+1])
    a[j]=a[j]^a[j+1]^(a[j+1]=a[j]);
return a[1];
   
}
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int n;
System.out.println("how much elements u want to insert?");
n=sc.nextInt();
int a[]=new int[n];

System.out.println("enter "+n+" numbers :");
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
System.out.println("second largest no. is "+sl(a));
  }
}

No comments:

Post a Comment