Tri de tableaux
Fermé
DAD
-
2 avril 2008 à 15:00
Mahmah Messages postés 496 Date d'inscription lundi 17 septembre 2007 Statut Membre Dernière intervention 22 juin 2010 - 2 avril 2008 à 16:50
Mahmah Messages postés 496 Date d'inscription lundi 17 septembre 2007 Statut Membre Dernière intervention 22 juin 2010 - 2 avril 2008 à 16:50
A voir également:
- Tri de tableaux
- Le fichier contient une liste de prénoms. triez ce tableau par ordre alphabétique des prénoms. quel mot est formé par les 6 premières lettres de la colonne code ? - Forum Bureautique
- Tableaux croisés dynamiques - Guide
- Impossible d'afficher le rapport de tableau croisé dynamique sur un rapport existant ✓ - Forum Excel
- Triez la liste comme sur cette illustration (attention, on ne voit que le début …). quel est le mot formé par les 6 dernières lettres de la colonne code ? - Forum Excel
- Il est trié sur la plateforme de départ ✓ - Forum Consommation et internet
2 réponses
Mahmah
Messages postés
496
Date d'inscription
lundi 17 septembre 2007
Statut
Membre
Dernière intervention
22 juin 2010
125
2 avril 2008 à 15:38
2 avril 2008 à 15:38
Bonjour,
Sans appel.
Compiling...
main.cpp
main.cpp(65) : error C2057: expected constant expression
main.cpp(65) : error C2466: cannot allocate an array of constant size 0
main.cpp(65) : error C2133: 'tin' : unknown size
main.cpp(67) : error C2057: expected constant expression
main.cpp(67) : error C2466: cannot allocate an array of constant size 0
main.cpp(67) : error C2133: 't' : unknown size
main.cpp(78) : error C2057: expected constant expression
main.cpp(78) : error C2466: cannot allocate an array of constant size 0
main.cpp(78) : error C2133: 'suivant' : unknown size
main.cpp(85) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(105) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
main.cpp(115) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(120) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(121) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(129) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
Les trois premières qui sont au début du main sont déjà suffisantes pour éviter un joli seg fault.
Essaie d'activer un peu plus de retours de la part de ton compilateur, ça peut aider...
M.
Sans appel.
Compiling...
main.cpp
main.cpp(65) : error C2057: expected constant expression
main.cpp(65) : error C2466: cannot allocate an array of constant size 0
main.cpp(65) : error C2133: 'tin' : unknown size
main.cpp(67) : error C2057: expected constant expression
main.cpp(67) : error C2466: cannot allocate an array of constant size 0
main.cpp(67) : error C2133: 't' : unknown size
main.cpp(78) : error C2057: expected constant expression
main.cpp(78) : error C2466: cannot allocate an array of constant size 0
main.cpp(78) : error C2133: 'suivant' : unknown size
main.cpp(85) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(105) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
main.cpp(115) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(120) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(121) : warning C4244: '=' : conversion from 'int' to 'float', possible loss of data
main.cpp(129) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
Les trois premières qui sont au début du main sont déjà suffisantes pour éviter un joli seg fault.
Essaie d'activer un peu plus de retours de la part de ton compilateur, ça peut aider...
M.
Correction de tes 2 méthodes :
Le début de ton main :
struct meteo * saisie (int *n)
{
int i, nb;
struct meteo *t;
printf("donnez la taille de votre tableau\n");
scanf("%d",&nb);
t = (struct meteo *)calloc(nb, sizeof(struct meteo));
for(i=0;i<nb;i++)
{
scanf("%f",&t[i].tempmin);
scanf("%f",&t[i].tempmax);
scanf("%d",&t[i].hygro);
scanf("%f",&t[i].pluis);
}
*n = nb;
return t;
}
void affiche(int n ,struct meteo *t)
{
int i;
printf("la taille du tableau:%d\n",n);
for(i=0;i<n;i++)
{
printf("%f\n",t[i].tempmin);
printf("%f\n",t[i].tempmax);
printf("%d\n",t[i].hygro);
printf("%f\n",t[i].pluis);
}
}
Le début de ton main :
int main()
{
int n; /*nombre de valeurs à trier*/
float *tin; /*le tableau retourne*/
int entiere ; /*la valeur entiiere à retournee*/
struct meteo *tab; /*le tableau saisie par l utilisateur*/
tab = saisie(&n);
affiche(n,tab);
}
2 avril 2008 à 16:31
j ai pas tres bien compri ou etait l erreure .
2 avril 2008 à 16:50
int main() { int n; /*nombre de valeurs à trier*/ float tin[n]; /*le tableau retourne*/Le compilateur, le mien en tout cas, veut savoir la taille du tableau qu'il doit mettre dans sa pile. Tous les compilos ne sont pas forcément aussi tatasses mais ici l'erreur semble là.
int main() { const int n = 22; /*nombre de valeurs à trier*/ float tin[n]; /*le tableau retourne*/lui irait par exemple.
int main() { int n; /*nombre de valeurs à trier*/ float *tin = NULL; /*le tableau retourne*/ ... n = 22; tin = (float*) malloc( n * sizeof( float ) ); ... free ( tin );irait aussi.
M.