Advertisement
Guest User

hrsrh

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.85 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. struct symStat
  8. {
  9.     char symb;
  10.     unsigned int freq;
  11. };
  12.  
  13. struct rotlaustTreFell
  14. {
  15.     rotlaustTreFell *left;
  16.     rotlaustTreFell *right;
  17.     char symb;
  18.     unsigned int freq;    
  19. };
  20.  
  21. union code
  22. {
  23.     unsigned char zippedWord;
  24.  
  25.     struct byte
  26.     {
  27.         unsigned b1:1;
  28.         unsigned b2:1;
  29.         unsigned b3:1;
  30.         unsigned b4:1;
  31.         unsigned b5:1;
  32.         unsigned b6:1;
  33.         unsigned b7:1;
  34.         unsigned b8:1;      
  35.     }byte;
  36. };
  37.  
  38. bool comparision( rotlaustTreFell *mas1, char *mas2, int poz, int size, char a )
  39. {
  40.     bool isa = false;
  41.     for ( int i = 0; i < poz; i++ )
  42.     {
  43.         if ( a == mas1[ i ].symb )
  44.             isa = true;
  45.     }    
  46.     return isa;
  47. }
  48.  
  49. int main(  )
  50. {
  51.     setlocale( LC_ALL, "rus" );
  52.     fstream file1( "random.txt" );
  53.     int size = 0;
  54.     file1.seekg( 0, std::ios::end );
  55.     size = file1.tellg(  );
  56.     cout << "Вес файла = " << size << " баит." << '\n';
  57.  
  58.     fstream in( "random.txt" );
  59.     char *filearr = new char[ size ];
  60.     in >> filearr;
  61.     in.close(  );
  62.    
  63.     char symb;  
  64.  
  65.     rotlaustTreFell tar;
  66.  
  67.     rotlaustTreFell *statmas = new rotlaustTreFell[ size ];
  68.     statmas -> freq = 0;
  69.  
  70.     for ( int i = 0; i < size; i++ )
  71.     {
  72.         //if ( comparision( statmas, filearr, i, size, statmas[ i ].symb ) == true )
  73.             //break;
  74.         statmas[ i ].symb = filearr[ i ];
  75.         statmas[ i ].freq = 0;
  76.         for ( int j = 0; j < size; j++ )
  77.         {
  78.             if ( statmas[ i ].symb == filearr[ j ] )
  79.             {
  80.                 statmas[ i ].freq++;
  81.             }
  82.         }
  83.         cout << statmas[ i ].symb << ' ' << statmas[ i ].freq << '\n';
  84.     }
  85.    
  86.    
  87.        
  88.     delete [  ]filearr;
  89.     file1.close();    
  90.     return 0;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement