Ok
Now i have all 3 functions like this
Code:
void LeVetor(int num[], int n)
{
int i, x, tmp;
srand(time(NULL));
// Inicia o array
for(i = 0;i < TAM;++i)
num[i] = i;
// Embaralha o array
for (i = TAM; i > 1;)
{
x = rand() % i;
--i;
tmp = num[x];
num[x] = num[i];
num[i] = tmp;
}
for(i = 0;i < 4;++i)
printf("%d\n", num[i]);
}
void bubbleSort(int v[], int n)
{
int i, j, temp;
for (i = n; i > 0; i--)
for (j = 1; j < i; j++)
if(v[j-1] > v[j])
{
temp = v[j-1];
v[j-1] = v[j];
v[j] = temp;
}
}
void vetorOrdenado()
{
int num[TAM];
int i;
int n=4;
printf ("\n*=============================================================================*\n");
printf ("| >>>>Numeros random<<<< |\n");
printf ("*=============================================================================*\n");
printf (" \n");
LeVetor(num, n);
// Iteração através do array. Os números já estão random
for(i = 0;i <4;++i)
printf("%d\n", num[i]);
printf("\n");
bubbleSort(num, 4);
printf ("\n*=============================================================================*\n");
printf ("| >>>>Vetor ordenado<<<< |\n");
printf ("*=============================================================================*\n");
printf (" \n");
for(i=0; i<4; i++)
{
printf("%d\n",num[i]);
}
}
Now i have that function who must give me 4 numbers (gonna call leVetor())
Then the user will be asked to sort those numbers
Finally i must compare with vetorOrdenado() the two arrays and return 1 or 0
So what i have so far is
Code:
int jogo1Gp3(int num[], int n)
{
int vet[3], i;
system("cls");
printf ("\n*=============================================================================*\n");
printf ("| >>>>Ordenacao rapida<<<< |\n");
printf ("*=============================================================================*\n");
printf (" \n");
leVetor();
printf("\nOrdene os 4 primeiros numeros de forma ascendente\n");
for (i=0; i<=3; i++)
{
printf("Ordene estes numeros ");
scanf("%d", &vet[i]);
}
if(vet[i]==vetorOrdenado_jogo(num,n))
printf("They are equal");
}
I have this error
error: void value not ignored as it ought to be|
warning: zero-length ms_printf format string [-Wformat-zero-length]|