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
|
//---------------------------------------------------------------------------
#include <vcl.h>
#include <string>
//#include <conio.h>
//#include <stdio.h>
//#include <cstring.h>
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
#include <conio.h>
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char pChaine[34] = {'(', '(', 'a', 'g', '+', 'c', 'd', 'x', 'q', 'q', 'd', ')', 'x', '(',
'b', 'v', '*', 'y', 'u', '-', 'l', 'm', ')', ')', '+', '(', 'x',
'x', '-', 'b', 'g', ')', ';'};
std::vector< char > pSeg;
int increment_max = 0;
int index_parent_beg = 1;
int index_parent_end = 13;
int i = 0;
for (int k = index_parent_beg; k <= index_parent_end; k++) // extraction d'un segment de char
{
pSeg.push_back(pChaine[k]);
}
for (int r = 0; r < pSeg.size(); r++)
{
cout << pSeg[r] << endl; // pSeg contient un sous ensemble de pChaine
}
string tampon_1S = "";
char tampon_1[5];
string tampon_2S = "";
char tampon_2[5];
for (int i = 0; i < pSeg.size(); i++)
{
if (pSeg[i] == 'x') // recherche du caracyère x dans pSeg
{
for (int g = 0; g < 5; g++)
{
tampon_1[g] = pSeg[g+i-5]; // enregistrement des caractère à gauche de x dans tampon_1
}
tampon_1[5] = ' '; // cloture de la chaine
for (int g = 0; g < 5; g++)
{
tampon_2[g] = pSeg[g+i]; // enregistrement des caractère à droite de x dans tampon_1
}
tampon_2[5] = ' '; // cloture de la chaine
}
tampon_1S = tampon_1;
tampon_2S = tampon_2;
}
cout << endl;
cout << endl;
cout << tampon_1S << endl;
getch();
return 0;
} |
Partager