1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <stdlib.h>
#include <stdio.h>
void permut(int tab[], int indice1, int indice2)
{
int tampon=tab[indice1];
tab[indice1]=tab[indice2];
tab[indice2]=tampon;
}
int main(int argv, char* argc[])
{
int tab2[3]; // tableau de 3 entiers
tab2[0]=3;tab2[1]=4;tab2[2]=5;
printf("Tableau origine : %i %i %i \n",tab2[0],tab2[1],tab2[2]);
permut(tab2, 0, 2); // on permute le premier et le dernier
printf("Tableau avec permutation : %i %i %i \n",tab2[0],tab2[1],tab2[2]);
return EXIT_SUCCESS;
} |
Partager