[c] tableau

Bonjour,

voici mon programme qui doit faire une permutation par rapport à la diagonal comme ceci

01234
10567
25089
368010
47910 0

j'ai du mal avec la permutation, on peut m'aider??? c'est surtout pour la diagonale!!

merci


#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define MAX 15

void main (void)


{

	int tableau[MAX][MAX];
	int x,y,nbre;
	int taille;

do
{
	printf("taille du tableau: 3,15\n");
	scanf("%d",&taille);

}while ((taille<3) || (taille>15));


srand (time (NULL));
	
for (x=0;x<taille;x++)
{
	for (y=0;y<taille;y++)
	{
		nbre =( rand () % 100)+ 1;
		tableau[x][y] = nbre;
	}
}


for (x=0;y<taille;x++)
{
	for (y=0;y<taille;y++)
	{
		printf ("%d\t", tableau[x][y]);
	}
	printf("\n");
}
printf("\n");


}


/* permutation
 

for (x=0;x<taille;x++)
{
	for(y=0;y<taille;y++)
	{
		if( )
		{
			nbre = nbre
		}
	}
}
*/
Configuration: Windows XP
Firefox 2.0.0.11

3 réponses

  1. je comprend pas ce que tu veux faire...
    tu veux permuter quoi ? comment ?
    1. voici un exemple

      d 4 6 7 9
      4 d 5 1 2
      6 5 d 8 3
      7 1 8 d 1
      9 2 3 1 d

      ce qui se trouve à la diagonale ne doit pas bouger!
      on doit permuter les chiffres identques par rapport à la diagonale!
      1. ok je vois essaye ça (si tu n'as pas compris quelquechose n'hesite pas a demander)
        #include <stdio.h>
        #include <stdlib.h>
        #include <time.h>
        
        #define MAX 15
        
        int main (void)
        
        
        {
        
        	int tableau[MAX][MAX];
        	int x,y,j=0,i,k=0;
        	int taille;
        
        do
        {
        	printf("taille du tableau: 3,15\n");
        	scanf("%d",&taille);
        
        }while ((taille<3) || (taille>15));
        
        
        srand (time (NULL));
        
        for (x=0;x<taille;x++)
        {
            tableau[x][x]=0;
        }
        
        for(x=0;x<taille;x++)
        {
            k++;
            for(y=0;y<taille;y++)
            {
                tableau[x][y+k]=(rand()%8)+1;
            }
        }
        
        for(x=0;x<taille;x++)
        {
            j++;
            for(y=0;y<taille;y++)
            {
                tableau[y+j][x]=tableau[x][y+j];
            }
        }
        
        for (x=0;x<taille;x++)
        {
        	for (y=0;y<taille;y++)
        	{
        		printf ("%d\t", tableau[x][y]);
        	}
        	printf("\n");
        }
        printf("\n");
        
        return 0;
        }