Problema com matriz
galera to com um trabalho aqui e preciso jogar numa matrix de 10 linhas por 6 colunas numeros aleatorios nao repetidos, porem ta gerando numeros completamente nada a ver e eu nao consigo achar o erro... alguem da um help ?
>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int a[10][6], i, k, j, x, existe;
srand(time(NULL));
//gerar matris
printf("Matriz\n");
for (k=0;k<10;k++)
{
for (i=0;i<6;i++)
{
a[k]*=rand()%60+1;*
existe=0;
for (j=0;j<i;j++)
{
* if (a[k]**==a[1][j])*
{
existe=1;
break;
}
}
if (existe)
i--;
}
//BubbleSort
for (i=0;i<6;i++)
{
for (j=i+1;j<6;j++)
{
* if (a[k]**>a[1][j])*
{
* x=a[k]**;*
* a[k]**=a[1][j];*
a[1][j]=x;
}
}
}
for (k=0;k<10;k++)
{
for (i=0;i<6;i++)
* printf("%3d",a[k]**);*
}
}
getch();
}
Discussão (1)
Carregando comentários...