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
| #include <iostream>
#include <string>
#include <vector>
using namespace std;
/* la fonction qui permet de récupérer le y ieme caractère de la
* x ieme chaîne
* @ in: tab: référence constante vers le tableau
* x: position de la chaine dans le tableau
* y: position du caracètre dans la chaine
* @ out: caractère trouvé
*/
const char get(const vector<string>& tab, size_t x, size_t y)
{
return tab[x][y];
}
int main()
{
vector<string> tab;
tab.push_back("poux");
tab.push_back("chou");
tab.push_back("tete");
for(size_t i=0;i<tab.size();i++)
cout<<get(tab,i,2)<<endl;
return 0;
} |