First commit
This commit is contained in:
63
IUT/Info1/TD/Exercices/10.6/tab.cpp
Normal file
63
IUT/Info1/TD/Exercices/10.6/tab.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "tab.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void permutation_lignes(
|
||||
unsigned int tab[][6],
|
||||
unsigned int index_ligne1,
|
||||
unsigned int index_ligne2,
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
unsigned int temp;
|
||||
|
||||
if ((index_ligne1 < nb_lignes) && (index_ligne2 < nb_lignes)) {
|
||||
for (unsigned int i = 0; i < nb_colonnes; i++) {
|
||||
temp = tab[index_ligne1][i];
|
||||
tab[index_ligne1][i] = tab[index_ligne2][i];
|
||||
tab[index_ligne2][i] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void permutation_colonnes(
|
||||
unsigned int tab[][6],
|
||||
unsigned int index_colonne1,
|
||||
unsigned int index_colonne2,
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
unsigned int temp;
|
||||
|
||||
if ((index_colonne1 < nb_colonnes) && (index_colonne2 < nb_colonnes)) {
|
||||
for (unsigned int i = 0; i < nb_lignes; i++) {
|
||||
temp = tab[i][index_colonne1];
|
||||
tab[i][index_colonne1] = tab[i][index_colonne2];
|
||||
tab[i][index_colonne2] = temp;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void afficher_tableau(
|
||||
unsigned int tab[][6],
|
||||
unsigned int nb_lignes,
|
||||
unsigned int nb_colonnes
|
||||
) {
|
||||
if ((nb_lignes == 0) || (nb_colonnes == 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < nb_lignes; i++) {
|
||||
cout << "| ";
|
||||
|
||||
for (unsigned int j = 0; j < nb_colonnes; j++) {
|
||||
cout << tab[i][j] << " ";
|
||||
}
|
||||
|
||||
cout << "|" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user