Matrice

j un exercice sur le tri des element entiere d'une matrice carrée comportant n lignes et n colonnes n entre 4 et 10
svp je veut la solution
Configuration: Windows Vista
Internet Explorer 7.0

5 réponses

  1. Ce n'est pas en ayant la solution toute faite que ça t'aidera.
    Tu ne l'auras pas.
    0
    1. Dommage, j'avais une solution... mais il n'y a que 3 lignes et 3 colonnes ;-)))
      0
      1. matrice[][]
        nbColonne
        nbLigne

        taille=nbColonne*nbLigne

        pour (i=0;i<taille-1;i++)
        {
        pour (j=i+1;i<taille;i++)
        {
        si(matrice[i%nbColonne][i/nbLigne]>matrice[j%nbColonne][j/nbLigne])
        {
        trans=matrice[i%nbColonne][i/nbLigne]
        matrice[i%nbColonne][i/nbLigne]=matrice[j%nbColonne][j/nbLigne]
        matrice[j%nbColonne][j/nbLigne]=trans
        }
        }
        }

        Grosso modo
        Attention c'est une division entière.
        0
    2. dsl je veu la resolution en algorithme ou bien en pascal c pas en c++ . merci de me repondre maintenant
      0
      1. Modérateur
        Salut

        Tu as un code à proposer ? :)

        Dans le langage souhaité si possible ...

        ++
        0
        1. bonsoir

          program matrice;
          uses wincrt;
          var m:array[1..10,1..10]of integer;
          t:array[1..100]of integer;
          i,j,k,x,taille,taillet:integer;
          begin
          write('la matrice doit etre carre: taillecolone=taille taille ligne= :');
          read(taille);
          writeln('remplir une matrice carre svp');

          for i:=1 to taille do
          for j:=1 to taille do
          begin
          write('m[',i,',',j,']= ');
          read(m[i,j]);
          end;
          writeln;
          for i:=1 to taille do
          begin
          for j:=1 to taille do
          write(m[i,j]:4); writeln;end;
          writeln;
          writeln('la matrice trie :');
          writeln;
          k:=1;
          for i:=1 to taille do
          for j:=1 to taille do
          begin
          t[k]:=m[i,j];
          k:=k+1;
          end;
          taillet:=taille*taille;
          for i:=1 to taillet-1 do
          for j:=i+1 to taillet do
          if t[i]>t[j] then
          begin
          x:=t[i];
          t[i]:=t[j];
          t[j]:=x;
          end;
          k:=1;
          for i:=1 to taille do
          for j:= 1 to taille do
          begin
          m[i,j]:=t[k];
          k:=k+1;
          end;
          for i:=1 to taille do
          begin
          for j:= 1 to taille do
          write(m[i,j]:4);writeln;end;

          readln;readln;
          end.
          0