Enviado em 29/03/2011 - 11:40h
SAlve galera, to com um problema no meu codigo, mas não sei muito bem o que é o problema. O codigo é pra organizar um array de inteiros então fiz uma função para o array e outra para mostrar o array organizado. Mas no entanto minha função para imrpimir não ta rodando nem a pau.
#include <stdio.h>
#include <stdlib.h>
void ordonnerTableau(int tab[], int taille);
void afficher(int tab);
int main()
{
int taille, tab[5] = {12, 3, 62, 26,0};
taille = (sizeof(tab)/sizeof(int)); // aqui a variavel taille tera o tamanho igual a quantidade de elementos do array
ordonnerTableau(tab, taille); //função para ordenar-lo em ordem crescente
afficher(&tab); // função que irá apenas mostrar o array organizado
return 0;
}
// Funções para ordenar o array e mostrar na tela
void ordonnerTableau(int tab[], int taille)
{
int i, j, aux = 0;
for(i=0; i<taille;i++) // para percorrer o meu array varias vezes ate organiza-lo
{
for (j=0; j<taille-1;j++)
{
if(tab[j] > tab[j+1]) //caso o valor atual seja maior que o valor futuro
{
aux = tab[j+1]; // variavel aux recebe o valor j+1
tab[j+1] = tab[j]; // j+1 agora pega o valor de j
tab[j] = aux; // j fica com o valor de aux
}
}
}
}
void afficher(int tab) // função para mostrar o array organizado
{
int i;
for(i=0; i<taille ; i++)
{
printf("%d\n", tab[i]);
}
}
#include <stdio.h>
#include <stdlib.h>
void ordonnerTableau(int tab[], int taille);
void afficher(int tab);
int main()
{
int taille, tab[5] = {12, 3, 62, 26,0};
taille = (sizeof(tab)/sizeof(int)); // aqui a variavel taille tera o tamanho igual a quantidade de elementos do array
ordonnerTableau(tab, taille); //função para ordenar-lo em ordem crescente
afficher(&tab); // função que irá apenas mostrar o array organizado
return 0;
}
// Funções para ordenar o array e mostrar na tela
void ordonnerTableau(int tab[], int taille)
{
int i, j, aux = 0;
for(i=0; i<taille;i++) // para percorrer o meu array varias vezes ate organiza-lo
{
for (j=0; j<taille-1;j++)
{
if(tab[j] > tab[j+1]) //caso o valor atual seja maior que o valor futuro
{
aux = tab[j+1]; // variavel aux recebe o valor j+1
tab[j+1] = tab[j]; // j+1 agora pega o valor de j
tab[j] = aux; // j fica com o valor de aux
}
}
}
}
void afficher(int tab) // função para mostrar o array organizado
{
int i;
for(i=0; i<taille ; i++)
{
printf("%d\n", tab[i]);
}
}