[C] Message

Résolu
Tachiarel Messages postés 7 Statut Membre -  
Tachiarel Messages postés 7 Statut Membre -
Bonjour,
Etudiant en informatique, je cherche à créer un programme de tri par insertion.
Cependant, mon compilateur GCC m'affiche, à la compilation, "two or more data types in declaration of 'trierSelection'", ligne 21.
Voici mon code :

#include <stdio.h>
#include <stdlib.h>
#define TAILLE_TABLEAU 10000
#define MAXIMUM 9999

int* genererTableau(int* tab, int taille)
{
    int i, intBuffer ;
    for(i = 0 ; i < taille ; i++)
    {
        intBuffer = MAXIMUM*rand() ;
        tab[i] = intBuffer ;
    }
    tab[taille] = '\0' ;
    return tab ;
}

void

void trierSelection(int tab[], int taille)
{
    int i, j, minLocal ;
    for(i = 0 ; i < taille ; i++)
    {
        minLocal = tab[i+1] ;
        for(j = i+1 ; j < taille ; j++)
        {
            if(tab[j] < minLocal)
                minLocal = tab[j] ;
        }
        tab[i+1] = minLocal ;
    }
}

void copierTableau(int* tab1, int* tab2, int taille)
{
    int i ;
    for(i = 0 ; i <= taille ; i++)
    {
        tab1[i] = tab2[i] ;
    }
}

void imprimer(int tab1[], int tab2[])
{
    int i ;
    for(i = 0 ; tab1[i] != '\0' || tab2[i] != '\0' ; i++)
    {
        printf("%d\t%d\n", tab1[i], tab2[i]) ;
    }
}



int main()
{
    int arrayBuffer[TAILLE_TABLEAU] ;
    int tableauEtudie[TAILLE_TABLEAU] ;
    genererTableau(arrayBuffer, TAILLE_TABLEAU) ;
	copierTableau(tableauEtudie, arrayBuffer, TAILLE_TABLEAU) ;
	trierSelection(tableauEtudie, TAILLE_TABLEAU) ;
	imprimer(arrayBuffer, tableauEtudie) ;
	return 0;
}



Verriez-vous où est l'erreur ?

Merci.
Configuration: Windows XP
Firefox 2.0.0.7

2 réponses

  1. ShaBoo Messages postés 406 Statut Membre 50
     
    #include <stdio.h>
    #include <stdlib.h>
    #define TAILLE_TABLEAU 10000
    #define MAXIMUM 9999
    
    int* genererTableau(int* tab, int taille)
    {
        int i, intBuffer ;
        for(i = 0 ; i < taille ; i++)
        {
            intBuffer = MAXIMUM*rand() ;
            tab[i] = intBuffer ;
        }
        tab[taille] = '\0' ;
        return tab ;
    }
    
    void
     il sert à quoi ce void ?
    
    
    void trierSelection(int tab[], int taille)
    {
        int i, j, minLocal ;
        for(i = 0 ; i < taille ; i++)
        {
            minLocal = tab[i+1] ;
            for(j = i+1 ; j < taille ; j++)
            {
                if(tab[j] < minLocal)
                    minLocal = tab[j] ;
            }
            tab[i+1] = minLocal ;
        }
    }
    
    void copierTableau(int* tab1, int* tab2, int taille)
    {
        int i ;
        for(i = 0 ; i <= taille ; i++)
        {
            tab1[i] = tab2[i] ;
        }
    }
    
    void imprimer(int tab1[], int tab2[])
    {
        int i ;
        for(i = 0 ; tab1[i] != '\0' || tab2[i] != '\0' ; i++)
        {
            printf("%d\t%d\n", tab1[i], tab2[i]) ;
        }
    }
    
    
    
    int main()
    {
        int arrayBuffer[TAILLE_TABLEAU] ;
        int tableauEtudie[TAILLE_TABLEAU] ;
        genererTableau(arrayBuffer, TAILLE_TABLEAU) ;
    	copierTableau(tableauEtudie, arrayBuffer, TAILLE_TABLEAU) ;
    	trierSelection(tableauEtudie, TAILLE_TABLEAU) ;
    	imprimer(arrayBuffer, tableauEtudie) ;
    	return 0;
    }
    
    0
  2. Tachiarel Messages postés 7 Statut Membre
     
    Ah mais ouaiiiiiiiiis !!!!
    Trop con...

    J'ai dû faire une erreur dans la syntaxe.
    Merciiiii !
    0