Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
33 views12 pages

#Include #Include #Include #Include #Include #Include

This document contains C++ code for analyzing text files. It defines a template class 'store' to store character keys and their frequencies. It includes a 'Remplir' function to increment the count of existing keys or add new keys to a vector. The main function takes a file as input, counts character frequencies, performs several calculations, and outputs results to two other files.

Uploaded by

ssfofo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views12 pages

#Include #Include #Include #Include #Include #Include

This document contains C++ code for analyzing text files. It defines a template class 'store' to store character keys and their frequencies. It includes a 'Remplir' function to increment the count of existing keys or add new keys to a vector. The main function takes a file as input, counts character frequencies, performs several calculations, and outputs results to two other files.

Uploaded by

ssfofo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 12

#include <iostream>

#include <ios>
#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>

#include <string.h>
#include <cstring>
#include <stdbool.h>
#include <cstdbool>
#include <math.h>
#include <cmath>
#include <iosfwd>
#include <fstream>
#include <vector>
#include <map>

#define Min(x, y) ( x < y ) ? x : y

#define Max(x, y) ( x > y ) ? x : y

#define Pi 3.14159

using namespace std;

template<class T, class V> class store {

public:
T key;

V ntimes;

//constructors for being aware away

store() { key = '\b'; ntimes = 0; }


store(T x, V y) { key = x; ntimes = y; }

inline store rstore( T x, V y) { return std::pair<T, V>(x, y); }

inline store vstore( T x, V y) { return store<T, V>( x, y ); }

//desconstructor for libering the storage space

~store() { }

};

////-------------------------------------------------------------------------------
------------

template<class T, class V> std::vector<store<T, V>> Remplir( T x,


std::vector<store<T, V>> k ){

bool exist = false;

for( auto& y : k ) {

if( x == y.key ) {
y.ntimes = y.ntimes + 1;

exist = true;
}else{

exist = false;
}
}
if( exist == false ) {

k.push_back(store<T, V>(x, 1));


}

return k;
}

////-------------------------------------------------------------------------------
--------------

int main(int argc, char** argv) {

if( argc != 4 ) {
fputs( " no enough parameters \n", stderr);

return 1; ///exit( 1 );

}else{

ifstream fptr;

fptr.open(argv[1], ios::in);

std::vector<store<char, unsigned int>> vect;

if( ! fptr.is_open() ) {

fputs("not possible to open file \n", stderr);

exit(1);

}else{
while( ! fptr.eof() ) {

char cch = fptr.get();

vect = Remplir(cch, vect);


}

fptr.close();

std::vector<float> sum;

for( auto& z : vect) {

float ax = log2( 2 - (log2( 1 + z.ntimes) / ( 1 + log2( 1 +


z.ntimes))));

ax = ax / ( 2 - ax);

int n = (int)(z.key); ///possible to use atoi(z.key) or


stoi(string(z.key));

ax = log2( 1 + ( ax * n) / ( n + ax));

ax = log2( 1 + ax) / ( 2 - log2( 1 + ax)) ; //better


reduction

sum.push_back(ax);

ofstream gptr;

gptr.open( argv[2], ios::out);

ofstream lptr;

lptr.open( argv[3], ios::out);

int dx = 0;
for( auto& z : vect) {

int n = (int)(z.key);

float yx = 1 - sum.at(dx);

float ax = -1 + exp( sum.at(dx) / yx ); //possible use of


complex with this exp()

float bx = -1 + exp( yx / (sum.at(dx)));

float sx = ax + bx;

float wx = ax * bx * ( bx - ax) / ( sx * sx * sx);

wx = log2( 1 + (wx * wx) / ( 1 + wx * wx));

sx = 1 - wx;

float tostor = log2( 1 + sx / ( 1 + n * wx));

float amp = log2( ( 1 + n * wx) / sx );

tostor = amp * tostor;

tostor = log2( 1 + (wx * tostor) / ( 1 + wx * tostor));

gptr << z.key << tostor;

lptr << tostor << '\b';


}

gptr.close();

lptr.close();

return 0;
}
}
}
because it is great opportunity to meet reality of valid level variation
Although wavy behavior can impact the entire exploitation of zingy traceability as
if it can be testimony of built in balance ::: thanks to works of Archimedes when
the driven

You might also like