Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- struct symStat
- {
- char symb;
- unsigned int freq;
- };
- struct rotlaustTreFell
- {
- rotlaustTreFell *left;
- rotlaustTreFell *right;
- char symb;
- unsigned int freq;
- };
- union code
- {
- unsigned char zippedWord;
- struct byte
- {
- unsigned b1:1;
- unsigned b2:1;
- unsigned b3:1;
- unsigned b4:1;
- unsigned b5:1;
- unsigned b6:1;
- unsigned b7:1;
- unsigned b8:1;
- }byte;
- };
- bool comparision( rotlaustTreFell *mas1, char *mas2, int poz, int size, char a )
- {
- bool isa = false;
- for ( int i = 0; i < poz; i++ )
- {
- if ( a == mas1[ i ].symb )
- isa = true;
- }
- return isa;
- }
- int main( )
- {
- setlocale( LC_ALL, "rus" );
- fstream file1( "random.txt" );
- int size = 0;
- file1.seekg( 0, std::ios::end );
- size = file1.tellg( );
- cout << "Вес файла = " << size << " баит." << '\n';
- fstream in( "random.txt" );
- char *filearr = new char[ size ];
- in >> filearr;
- in.close( );
- char symb;
- rotlaustTreFell tar;
- rotlaustTreFell *statmas = new rotlaustTreFell[ size ];
- statmas -> freq = 0;
- for ( int i = 0; i < size; i++ )
- {
- //if ( comparision( statmas, filearr, i, size, statmas[ i ].symb ) == true )
- //break;
- statmas[ i ].symb = filearr[ i ];
- statmas[ i ].freq = 0;
- for ( int j = 0; j < size; j++ )
- {
- if ( statmas[ i ].symb == filearr[ j ] )
- {
- statmas[ i ].freq++;
- }
- }
- cout << statmas[ i ].symb << ' ' << statmas[ i ].freq << '\n';
- }
- delete [ ]filearr;
- file1.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement