Forum INFOMATH
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le Deal du moment :
Funko POP! Jumbo One Piece Kaido Dragon Form : ...
Voir le deal
Le Deal du moment : -20%
-20% Récupérateur à eau mural 300 ...
Voir le deal
79 €

Matrice vers Tableau

2 participants

Aller en bas

matrice* - Matrice vers Tableau Empty Matrice vers Tableau

Message par Napoléon Ven 28 Mar - 11:23

Quel est l'algorithme qui transforme cette matrice en ce tableau


matrice* - Matrice vers Tableau Pb10

*******

matrice* - Matrice vers Tableau Pb210
Napoléon
Napoléon
Admin
Admin

Masculin
Nombre de messages : 2934
Localisation : Tunisie
Réputation : 122
Points : 7667
Date d'inscription : 19/03/2007

Feuille de personnage
Capacité linguistique:
matrice* - Matrice vers Tableau Left_bar_bleue999/1000matrice* - Matrice vers Tableau Empty_bar_bleue  (999/1000)

https://infomath.1fr1.net

Revenir en haut Aller en bas

matrice* - Matrice vers Tableau Empty Re: Matrice vers Tableau

Message par manianis Ven 28 Mar - 23:11

Vous avez dèjà posté cet exercice Nabil à ce que je pense.

manianis
Nombre Réel
Nombre Réel

Masculin
Nombre de messages : 975
Localisation : Tunisie
Réputation : 4
Points : 6050
Date d'inscription : 11/10/2007

Feuille de personnage
Capacité linguistique:
matrice* - Matrice vers Tableau Left_bar_bleue999/1000matrice* - Matrice vers Tableau Empty_bar_bleue  (999/1000)

http://manianis.sitesled.com/

Revenir en haut Aller en bas

matrice* - Matrice vers Tableau Empty Re: Matrice vers Tableau

Message par manianis Sam 29 Mar - 1:19

Code:
program matrice_vers_tableau;
const
  DIM = 5;

type
  mat = array [0..DIM - 1, 0..DIM - 1] of char;
  tab = array [0..DIM*DIM - 1] of char;

var
  i, j, k : integer;
  c : char;
  inc_i, inc_j : integer;
 
  m : mat;
  t : tab;
begin
  // initialiser la matrice
  c := 'A';
  for j:=0 to DIM-1 do begin
    for i:=0 to DIM-1 do begin
      m[j,i] := c;
      c := succ(c);
    end;
  end;
 
  // afficher la matrice
  Writeln('matrice');
  for j:=0 to DIM-1 do begin
    for i:=0 to DIM-1 do begin
      write(m[j,i],' ');
    end;
    writeln;
  end;
 
  // ranger la matrice dans le tableau
  i := 0; j := 0;
  inc_i := 1;  inc_j := -1;
  for k:=0 to DIM*DIM-1 do begin
    t[k] := m[j, i];
   
    i := i + inc_i;
    j := j + inc_j;
   
    (* descente *)
    if (j < 0) or (i >= DIM) then begin 
      if (i >= DIM) then begin
        i := DIM - 1;
        j := j + 2;
      end; 
      if (j < 0) then j := 0;
      inc_i := -1;
      inc_j := 1;
    end;
   
    (* montée *)
    if (i < 0) or (j >= DIM) then begin
      if (j >= DIM) then begin
        j := DIM - 1;
        i := i + 2;
      end;
      if (i < 0) then i := 0;
      inc_j := -1;
      inc_i := 1;
    end;
  end;
 
  // afficher le résultat
  Writeln('tableau');
  for k:=0 to DIM*DIM-1 do
      write(t[k], ' ');
     
  readln;
end.

manianis
Nombre Réel
Nombre Réel

Masculin
Nombre de messages : 975
Localisation : Tunisie
Réputation : 4
Points : 6050
Date d'inscription : 11/10/2007

Feuille de personnage
Capacité linguistique:
matrice* - Matrice vers Tableau Left_bar_bleue999/1000matrice* - Matrice vers Tableau Empty_bar_bleue  (999/1000)

http://manianis.sitesled.com/

Revenir en haut Aller en bas

matrice* - Matrice vers Tableau Empty Re: Matrice vers Tableau

Message par Contenu sponsorisé


Contenu sponsorisé


Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum