-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUFFMAN.CPP
More file actions
52 lines (51 loc) · 746 Bytes
/
HUFFMAN.CPP
File metadata and controls
52 lines (51 loc) · 746 Bytes
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
#include<iostream.h>
#include<conio.h>
#include<string.h>
void huffalgo();
class huff
{
float freq;
char a;
public:
void getvalue(char b,float f)
{
a=b;
freq=f;
}
friend ostream& operator<<(ostream &,huff);
};
ostream& operator<<(ostream &out,huff temp)
{
out<<temp.a;
out<<" "<<temp.freq<<endl;
return out;
}
void main()
{
char ch;
float f;
int n=10;
clrscr();
cout<<"\n how many alphabets\n";
cin>>n;
huff *obj;
obj=new huff[n];
cout<<"\n Enter char n its frequency\n";
for(int i=0;i<n;i++)
{
cin>>ch;
cin>>f;
obj[i].getvalue(ch,f);
}
cout<<"\n Given values are \n";
for(i=0;i<n;i++)
{
cout<<obj[i];
}
huffalgo();
delete [] obj;
getch();
}
void huffalgo()
{
}