-
Notifications
You must be signed in to change notification settings - Fork 0
/
huff.java
56 lines (56 loc) · 864 Bytes
/
huff.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.*;
class huff
{
public int a;
public char c;
public String s;
huff(int f,String k)
{
a=f;
c=k.charAt(1);
}
public static void main(String as[])
{
Scanner o=new Scanner(System.in);
huff d[]=new huff[5];
for(int i=0;i<5;i++)
{
d[i]=new huff(o.nextInt(),o.nextLine());
}
for(int i=0;i<5;i++)
for(int j=i+1;j<5;j++)
{
if(d[i].a>d[j].a)
{
int t=d[i].a;
d[i].a=d[j].a;
d[j].a=t;
char f=d[i].c;
d[i].c=d[j].c;
d[j].c=f;
}
}
System.out.println();
System.out.println();
for(int i=0;i<5;i++)
{
System.out.println(d[i].a+" "+d[i].c);
}
System.out.println();
System.out.println();
d[0].s="0";
d[1].s="1";
d[1].a=d[1].a+d[0].a;
if(d[2].a>=d[1].a)
{
d[2].a+=d[1].a;
d[0].s="00";
d[1].s="01";
d[2].
}
else
{
if(d[3].a>=d[1].a)
}
}
}