[C] Message
Résolu
Tachiarel
Messages postés
7
Date d'inscription
Statut
Membre
Dernière intervention
-
Tachiarel Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
Tachiarel Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
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 :
Verriez-vous où est l'erreur ?
Merci.
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.
A voir également:
- [C] Message
- Recuperer message whatsapp supprimé - Guide
- Message supprimé whatsapp - Guide
- Message absence thunderbird - Guide
- Epingler un message whatsapp - Accueil - Messagerie instantanée
- Message du pere noel gratuit whatsapp - Accueil - Messagerie instantanée
2 réponses
#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;
}