A voir également:
- Remplissage d'un tableau par des chaines
- Tableau word - Guide
- Recherche automatique des chaînes ne fonctionne pas - Guide
- Trier un tableau excel - Guide
- Imprimer un tableau excel - Guide
- Tableau ascii - Guide
2 réponses
Salut,
Pas besoin d'un tableau à deux dimensions en C++ pour faire un tableau de chaînes de caractères. Utilise un tableau de string.
Pas besoin d'un tableau à deux dimensions en C++ pour faire un tableau de chaînes de caractères. Utilise un tableau de string.
std::string tab[]={"coucou","comment","ca","va"};
tu peux utiliser vector et string pour les chaines de caractère.
voici un exemple de vector 2D d'entier.
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
vector<vector<int> > items ( 5, vector<int> ( 5 ) );
int k = 0;
for ( int i = 0; i < 5; i++ ) {
for ( int j = 0; j < 5; j++ )
items[i][j] = k++;
}
for ( int i = 0; i < 5; i++ ) {
for ( int j = 0; j < 5; j++ )
cout<< setw ( 3 ) << items[i][j] <<' ';
cout<<'\n';
}
}
voici un exemple de vector 2D d'entier.
#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
vector<vector<int> > items ( 5, vector<int> ( 5 ) );
int k = 0;
for ( int i = 0; i < 5; i++ ) {
for ( int j = 0; j < 5; j++ )
items[i][j] = k++;
}
for ( int i = 0; i < 5; i++ ) {
for ( int j = 0; j < 5; j++ )
cout<< setw ( 3 ) << items[i][j] <<' ';
cout<<'\n';
}
}