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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
|
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <fstream>
#include <stdio.h>
#include <string.h>
#include <sstream>
using namespace std;
template<typename T>
string to_string( const T & Value );
int calcule(string mo);
int reduit(int vv);
int main()
{
ofstream fichier("test.txt", ios::out | ios::trunc);
int ii;
long cont;
cont = 0;
string mot;
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
int i;
int j;
string lt1;
string lt2;
string lt3;
string lt4;
string lt5;
string lt6;
string lt7;
string lt8;
string lt9;
string lt10;
int taille;
string chaine;
chaine = "zxw"; // Chaine de caractere
taille = chaine.length();
string t1[taille];
string t2[taille];
string t3[taille];
string t4[taille];
string t5[taille];
string t6[taille];
string t7[taille];
string t8[taille];
string t9[taille];
string t10[taille];
for (ii=0; ii<taille; ii++) // Rempli des tableaux avec la chaine chaine
{
t1[ii] = chaine.substr(ii,1);
t2[ii] = chaine.substr(ii,1);
t3[ii] = chaine.substr(ii,1);
t4[ii] = chaine.substr(ii,1);
t5[ii] = chaine.substr(ii,1);
t6[ii] = chaine.substr(ii,1);
t7[ii] = chaine.substr(ii,1);
t8[ii] = chaine.substr(ii,1);
t9[ii] = chaine.substr(ii,1);
t10[ii] = chaine.substr(ii,1);
}
for(f=0; f<taille; f++)
{
for(e=0; e<taille; e++)
{
for(d=0; d<taille; d++)
{
for(c=0; c<taille; c++)
{
for(b=0; b<taille; b++)
{
for(a=0; a<taille; a++)
{
lt1 = t1[a];
lt2 = t2[b];
lt3 = t3[c];
lt4 = t4[d];
lt5 = t5[e];
lt6 = t5[f];
mot = lt6 += lt5 += lt4+= lt3 += lt2 += lt1 ;
cout<<mot<<" "<<" Valeur non réduite "<< calcule(mot)<<" "<< "Valeur réduite"<<" "<<reduit(calcule(mot))<<endl;
fichier<<mot<<" "<<" Valeur non réduite "<< calcule(mot)<<" "<< "Valeur réduite"<<" "<<reduit(calcule(mot))<<endl;
cont++;
}
}
}
}
}
}
cout<< "Il y a "<<cont<<" entrées"<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
///////////////Fonction posant problème////////:ccool://////////////////////////
int reduit(int vv)
{
string chain = to_string(vv);
int t;
t = chain.length();
int ent;
int res;
res = 0;
char car;
int i;
for(i=0; i<t; i++)
{
car = chain[i] ;
ent = car - '0';
res = res + ent;
}
//commentaires// if(res<10)
///à // reduit(res);
//enlever// else
return res;
}
////////////////////////////////////////////////////
int calcule(string mo)
{
int i;
int val;
int valT;
valT = 0;
val = 0;
int t;
t = mo.length();
for(i=0; i<t; i++)
{
switch (mo[i])
{
case 97:
val = 1;
break;
case 98:
val = 2;
break;
case 99:
val = 3;
break;
case 100:
val = 4;
break;
case 101:
val = 5;
break;
case 102:
val = 6;
break;
case 103:
val = 7;
break;
case 104:
val = 8;
break;
case 105:
val = 9;
break;
case 106:
val = 10;
break;
case 107:
val = 11;
break;
case 108:
val = 12;
break;
case 109:
val = 13;
break;
case 110:
val = 14;
break;
case 111:
val = 15;
break;
case 112:
val = 16;
break;
case 113:
val = 17;
break;
case 114:
val = 18;
break;
case 115:
val = 19;
break;
case 116:
val = 20;
break;
case 117:
val = 21;
break;
case 118:
val = 22;
break;
case 119:
val = 23;
break;
case 120:
val = 24;
break;
case 121:
val = 25;
break;
case 122:
val = 26;
break;
default:
val = 0;
break;
}
valT = valT + val;
}
return valT;
}
////////////////////////////////////////////////////
template<typename T>
string to_string( const T & Value )
{
// utiliser un flux de sortie pour créer la chaîne
std::ostringstream oss;
// écrire la valeur dans le flux
oss << Value;
// renvoyer une string
return oss.str();
}
//////////////////////////////////////////////////////: |
Partager