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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
| // Directives du préprocesseurs
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<list>
#include<fstream>
using namespace std;
//#include "matrice.h"
//#ifndef MATRICE
//#define MATRICE
using namespace std;
//Classe point
class point{
private :
int O;
int H;
vector<int> S;
public :
//constructeur
point(int N);
//Constructeur par copie
// matrice ( const matrice & );
//destructeur
~point();
//méthodes
void Saisie(list<point> &LP,int N,int Z,vector<int> V);
void Affiche(list<point>::iterator it,list<point> LP,string nom);
void Sauv_file(list<point>::iterator it,list<point> LP,char f[],string nom);
void Insert(list<point> LP,int Z,vector<int> V);
};
//#endif
//constructeur
point::point(int N){
O=-1;
H=-1;
for(int i=0;i<N;i++){
S.push_back(i)=-1;
}
}
/*
//Constructeur par copie
template <class T> matrice<T>::matrice(const matrice<T> &m){
if((nl==1)&&(nc==1)){
cout<<"Erreur de taille"<<endl;
}
else{
nligne=nl;
ncolonne=nc;
coefligne = new vector<T>[nligne];
for(int i=0;i<nligne;i++){
coefligne[i] = vector<T>(ncolonne);
}
}
}
*/
//Destructeur
point::~point(){
}
//méthodes
int hach(vector<int> V){
int temp;
temp=0;
for(int i=0; i<V.size();i++){
temp=temp+(i*i)*V[i];
}
return(temp);
}
void point::Saisie(list<point> &LP,int N,int Z,vector<int> V){
for(int i=0;i<N;i++){
point temp;
temp.O=Z;
temp.H=hach(V);
temp.S=V;
LP.push_back(temp);
}
}
void point::Affiche(list<point>::iterator it,list<point> LP,string nom){
cout<<nom<<" : "<<endl;
for(int it=LP.begin();it!=LP.end();it++){
cout<<setw(3)<<*it<<" ";
// cout<<" "<<i<<" "<<j<<"<<Tab[i][j]<<endl;
}
cout<<endl;
}
void point::Sauv_file(list<point>::iterator it,list<point> LP,char f[],string nom){
ofstream Ecri;
// cout<<"Entrer le nom du fichier : ";
// cin>>f;
Ecri.open(f,ios::app);
Ecri<<nom<<" : "<<endl;
for(int it=LP.begin();it!=LP.end();it++){
cout<<setw(3)<<*it<<" ";
Ecri<<setw(3)<<*it<<" ";
// cout<<" "<<i<<" "<<j<<"<<Tab[i][j]<<endl;
}
Ecri<<endl;
Ecri.close();
}
void point::Insert(list<point> LP,int Z,vector<int> V){
point temp;
LP.pop_front;
temp.O=Z;
temp.H=hach(V);
temp.S=V;
P.push_back(temp);
}
void main(){
int n,z;
vector<int> s,s0;
list<point> lp;
list<point>::iterator it;
n=10;
z=100:
for (int i=0;i<n;i++)
s.push_back(i);
Saisie(Lp,n,z,s);
Affiche(it,Lp,"Liste tabou");
Sauv_file(it,Lp,'C:\\Documents and Settings\\Administrateur\\Bureau\\A Matrice\\Matrice\\Pointer\\Recherche tabou 09 04 04\\Test point\\point.txt',"Liste tabou");
z=255;
for (int i=0;i<n;i++)
s0.push_back(i*i);
Insert(Lp,z,s0);
Affiche(it,Lp,"Liste tabou");
Sauv_file(it,Lp,'C:\\Documents and Settings\\Administrateur\\Bureau\\A Matrice\\Matrice\\Pointer\\Recherche tabou 09 04 04\\Test point\\point.txt',"Liste tabou");
} |
Partager