File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package easyq ;
2+ import java .util .*;
3+ public class min
4+ { static Scanner nav =new Scanner (System .in );
5+ static int array [],temp ,size ;
6+ static int good ,bad ;
7+ public min (int size )
8+ {
9+ this .size =size ;
10+ array =new int [size ];
11+ good =bad =0 ;
12+ }
13+
14+ public static void input ()
15+ { System .out .println ("INPUT element in array :-> >" );
16+ for (int i =0 ;i <size ;i ++)
17+ {
18+ array [i ]=nav .nextInt ();
19+ }
20+ }
21+ public static void minswap (int k )
22+ { int min =100 ;
23+ for (int i =0 ;i <size ;i ++)
24+ {
25+ if (array [i ]<=k )
26+ good ++;
27+ else
28+ bad ++;
29+ }
30+ System .out .println ("bad -" +bad +"Good -" +good );
31+ for (int i =0 ;i <size ;i ++)
32+ { int b =bad ;
33+ for ( int j =0 ;j <size ;j ++)
34+ {
35+ if (array [j ]<=k )
36+ b --;
37+ }
38+ if (b <=min )
39+ min =b ;
40+ System .out .println ("min __" +min );
41+ }
42+
43+ }
44+ public static void main (String NAVEEN [])
45+ {
46+ System .out .println ("Enter the size of array" );
47+ min n =new min (nav .nextInt ());
48+ input ();
49+ System .out .println ("Enter K value" );
50+ minswap (nav .nextInt ());
51+ }
52+
53+ }
You can’t perform that action at this time.
0 commit comments