diff options
| author | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
|---|---|---|
| committer | Gaspard Coulet <gaspard.coulet@mines-ales.org> | 2021-04-28 23:05:53 +0200 |
| commit | 9fe033ea88c2f705ec18c232873d056e0c229d72 (patch) | |
| tree | 0647dc8c51610c7336c88c04de2068ea14b21e17 /sem_2/HLIN202/TP/TP7-8/ex9 | |
Initial commit
Diffstat (limited to 'sem_2/HLIN202/TP/TP7-8/ex9')
| -rw-r--r-- | sem_2/HLIN202/TP/TP7-8/ex9/exo9 | bin | 0 -> 9237 bytes | |||
| -rw-r--r-- | sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp | 41 |
2 files changed, 41 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP7-8/ex9/exo9 b/sem_2/HLIN202/TP/TP7-8/ex9/exo9 Binary files differnew file mode 100644 index 0000000..55c4d59 --- /dev/null +++ b/sem_2/HLIN202/TP/TP7-8/ex9/exo9 diff --git a/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp b/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp new file mode 100644 index 0000000..021365f --- /dev/null +++ b/sem_2/HLIN202/TP/TP7-8/ex9/exo9.cpp @@ -0,0 +1,41 @@ +#include<iostream>
+
+void permut ( int tab[], int d, int i) {
+ int Temp[d];
+ for (int j =0; j < d; j ++) {
+ Temp[j]=tab[j];
+ }
+ if ( i > 0) {
+ for (int j = 0; j < d ; j ++) {
+ if (j-i < 0 ) {
+ tab[j]=Temp[d-i+j];
+ }
+ else {
+ tab[j]= Temp[j-i];
+ }
+ }
+ }
+ else if ( i < 0 ) {
+ for (int j = 0; j<d;j ++) {
+ if (j-i==d) {
+ tab[j]=Temp[d+i-j];
+ }
+ else if ( j-i > d) {
+ tab[j]=Temp[d-j];
+ }
+ else {
+ tab[j]=Temp[j-i];
+ }
+ }
+ }
+}
+int main () {
+ int tab[6] = {0,1,2,3,4,5};
+ //Ce programme effectue une rotation de i etapes sur le tableau donné ( le sens change en fonction du signe de i)
+ permut ( tab, 6, 2);
+ for (int i =0; i< 6; i ++) {
+ std::cout<<tab[i]<<" ";
+ }
+ std::cout<<std::endl;
+ return 0;
+}
|
