| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 
 | #include <stdio.h>
typedef int composante;
void lecture(composante *t,int *nb)
 {
  int i;
  puts("nombre de valeurs à entrer ? ");
  scanf("%d",nb);
  for(i=1;i<=*nb;i++)
   {
    printf("%dième valeur : ",i);
    scanf("%d",t++);
   }
 }
void affiche(composante *t, int max)
 {
  int i;
  for(i=0;i<max;i++) printf("%d ",*t++);
  puts(" ");
 }
void decale_bas(composante *deb, int max)
 {
  composante c,*t;
  t=deb+(max-1);
  c=*t;
  while (t>deb) {*t=*(t-1);t--;}
  *t=c;
 }
void decale_haut(composante *t, int nb)
 {
  composante c;int i;
  c=*t;
  for (i=1;i<nb;i++) {*t=*(t+1);t++;}
  *t=c;
 }
void main(void)
 {
  composante tableau[100];
  int nombre;
  lecture(tableau,&nombre);
  puts("tableau initial :");
  affiche(tableau,nombre);
  decale_haut(tableau,nombre);
  puts("décalage vers le haut :");
  affiche(tableau,nombre);
  decale_bas(tableau,nombre);
  puts("décalage vers le bas :");
  affiche(tableau,nombre);
 } | 
Partager