Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
dissa2 old.docx
Скачиваний:
27
Добавлен:
12.06.2018
Размер:
790.09 Кб
Скачать

Приложение а

#include <iostream>

#include <fstream>

#include <string>

#include <vector>

#include <map>

#include <cmath>

#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <algorithm>

#define _CRT_SECURE_NO_WARNINGS ;

using namespace std;

void error (const char * text1, const char * text2 = ""){

std::cerr << text1 << ' ' << text2 << endl;

exit(1);

}

void postClast (std::vector < std::vector < int > > vIdStr,std::vector < std::vector <std::map<int,float> > > vMapCls, int th3, float th4, std::vector < std::vector < int > > & vOutIdStr, std::vector < std::vector <std::map<int,float> > > & vOutMapCls){

std::multimap <int,int> SizeMapCls;

int n=0;

for (int k=0; k<vMapCls.size(); k++)

SizeMapCls.insert(std::pair<int,int>( vMapCls[k].size(),k ));

std::vector <int> vCheck;

for (std::multimap<int,int>::const_reverse_iterator rit = SizeMapCls.rbegin(); rit != SizeMapCls.rend(); ++rit){

bool flg_x=false;

for (int q=0; q<vCheck.size(); q++){

if (vCheck[q] == (*rit).second)

flg_x=true;

}

if (vIdStr[(*rit).second].size() > th3 && flg_x==false){

vOutIdStr.resize( vOutIdStr.size()+1 );

vOutMapCls.resize( vOutMapCls.size()+1 );

for (int h=0; h< vIdStr[(*rit).second].size(); h++){

vOutIdStr[n].push_back(vIdStr[(*rit).second][h]);

vOutMapCls[n].push_back(vMapCls[(*rit).second][h]);

Продолжение Приложения а

}

for ( std::multimap<int,int>::const_reverse_iterator tir = rit; tir != SizeMapCls.rend(); ++tir){

bool flg_y=false;

for (int q=0; q<vCheck.size(); q++){

if (vCheck[q] == (*tir).second)

flg_y=true;

}

if ((*rit).second!=(*tir).second && flg_y==false){

int cnt=0;

if (vIdStr[(*tir).second].size() > th3){

for (int w=0; w<vIdStr[(*rit).second].size(); w++){

for (int z=0; z<vIdStr[(*tir).second].size(); z++){

if (vIdStr[(*rit).second][w] == vIdStr[(*tir).second][z]) {

cnt++;

break;

}

}

}

if ( cnt > vIdStr[(*tir).second].size()*th4){

for (int g=0; g< vIdStr[(*tir).second].size(); g++){

bool be=false;

for (int j=0; j< vOutIdStr[n].size(); j++){

if(vOutIdStr[n][j] == vIdStr[(*tir).second][g])

be=true;

}

if (be==false){

vOutIdStr[n].push_back(vIdStr[(*tir).second][g]);

vOutMapCls[n].push_back(vMapCls[(*tir).second][g]);

}

}

vCheck.push_back((*tir).second);

}

}

}

Продолжение Приложения а

}

n++;

}

}

}

void firstClast (std::vector < std::map <int,float> > vCls, std::vector < int > vId, float th2, std::vector < std::vector <std::map<int,float> > > & vMapCls, std::vector < std::vector < int > > & vIdStr){

std::multimap<int,int> vMapRang;

for (int id=0; id<vCls.size(); id++)

vMapRang.insert(std::pair<int,int>(vCls[id].size(),id));

int cnt=0;

for ( std::multimap<int,int>::const_reverse_iterator fst = vMapRang.rbegin(); fst != vMapRang.rend(); ++fst){

bool flg=false;

for (int a=0; a<vIdStr.size();a++){

for (int b=0; b<vIdStr[a].size();b++){

int tmp=(*fst).second;

if(vId[ (*fst).second ] == vIdStr[a][b]){

flg=true;

break;

}

}

if (flg==true)

break;

}

if (flg==false){

vMapCls.resize(vMapCls.size()+1);

vIdStr.resize(vIdStr.size()+1);

vMapCls[cnt].push_back(vCls[ (*fst).second ]);

vIdStr[cnt].push_back(vId[(*fst).second ]);

for ( std::multimap<int,int>::const_reverse_iterator scnd = fst; scnd != vMapRang.rend(); ++scnd){

if (fst!=scnd){

std::map<int,float>::const_iterator itv = vCls[ (*fst).second ].begin();

int comp=0;

for ( std::map<int,float>::const_iterator itr = vCls[ (*scnd).second ].begin(); itr != vCls[ (*scnd).second ].end(); ++itr){

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]