Utiliser les pointeurs pour les tableaux
Résolu/Fermé
yadhus
Messages postés
33
Date d'inscription
dimanche 17 février 2008
Statut
Membre
Dernière intervention
16 mars 2009
-
5 mars 2008 à 17:40
dekker Messages postés 371 Date d'inscription samedi 5 janvier 2008 Statut Membre Dernière intervention 27 octobre 2009 - 5 mars 2008 à 17:55
dekker Messages postés 371 Date d'inscription samedi 5 janvier 2008 Statut Membre Dernière intervention 27 octobre 2009 - 5 mars 2008 à 17:55
A voir également:
- Utiliser les pointeurs pour les tableaux
- Comment utiliser chromecast - Guide
- Tableaux croisés dynamiques - Guide
- Comment utiliser wetransfer gratuit ? - Guide
- Utiliser tablette comme ecran - Guide
- Utiliser iphone comme webcam - Guide
2 réponses
dekker
Messages postés
371
Date d'inscription
samedi 5 janvier 2008
Statut
Membre
Dernière intervention
27 octobre 2009
12
5 mars 2008 à 17:47
5 mars 2008 à 17:47
tu te galere la vie je pense
atta je reflechie a ton problome ;)
je te rep dans 30 minute ^^
tu a pas forcement besion des pointeur tu peu ressoudre sa avec un compteur ( pour avoir l'indice du tableau que tu passe en refence dans tes fonction " variable globale" )
je te fait un code dans 30 minute ;)
atta je reflechie a ton problome ;)
je te rep dans 30 minute ^^
tu a pas forcement besion des pointeur tu peu ressoudre sa avec un compteur ( pour avoir l'indice du tableau que tu passe en refence dans tes fonction " variable globale" )
je te fait un code dans 30 minute ;)
dekker
Messages postés
371
Date d'inscription
samedi 5 janvier 2008
Statut
Membre
Dernière intervention
27 octobre 2009
12
5 mars 2008 à 17:55
5 mars 2008 à 17:55
tien j ai retrouver un de mes TP sur les tableau si tu veut plus d'info , paularch79@hotmail.com je suis en 1er IRIS
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
void random(int tab[], int n)
{
int nb;
srand( time(0));
for (int cpt=0; cpt<n ;cpt++)
{
nb=(rand()%100);
tab[cpt]=nb;
}
}
void afficher(int tab[], int n)
{
for ( int i=0;i<n;i++)
cout<<tab[i]<<" ";
}
void valmanu (int tab[], int n)
{
int a;
for (int indice=0;indice<n;indice++)
{
cout<<"vous avez rentrer "<< indice<<" chiffre"<<endl;
cin>>a;
tab[indice]=a;
}
}
void totaltab (int tab[],int n, int &total)
{
for(int indice=0;indice<n;indice++)
{
total=total+tab[indice];
}
}
void moyentab ( int tab [],int n,int total, float &moyenne )
{
moyenne=(total/(float)10);
}
void valmax (int tab [],int n,int &max)
{
max=tab[0];
for (int indice=0;indice<n;indice++)
{
if ( tab[indice]>max)
max=tab[indice];
}
}
void valmin (int tab [],int n,int &min)
{
min=tab[0];
for (int indice=0;indice<n;indice++)
{
if ( tab[indice]<min)
min=tab[indice];
}
}
int main()
{
const int NB=10;
int tab[NB];
int total=0;
float moyenne;
int max ;
int min;
int choix;
cout<<"tableau aleatoir tapez 1 "<<endl;
cout<<"tableau manuel tapez 2"<<endl;
cout<<"une autre touche pour quitter"<<endl;
cin>> choix;
switch (choix)
{
case 1:
random(tab, NB);
afficher(tab, NB);
cout<<endl;
totaltab (tab, NB ,total );
cout<<"la somme est egale a "<<total<<endl;
moyentab ( tab, NB, total, moyenne );
cout<<"la moyenne est " <<moyenne<<endl ;
valmax ( tab , NB, max);
cout<<"le max est " <<max<<endl;
valmin ( tab , NB, min);
cout <<"le min est " <<min<<endl;
break;
case 2 :
valmanu (tab, NB) ;
afficher(tab, NB);
cout<<endl;
moyentab ( tab, NB, total, moyenne );
cout<<"la moyenne est " <<moyenne<<endl ;
valmax ( tab , NB, max);
cout<<"le max est " <<max<<endl;
valmin ( tab , NB, min);
cout <<"le min est " <<min<<endl;
break;
default: cout<< " quitter " ;
}
#include <iostream.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
void random(int tab[], int n)
{
int nb;
srand( time(0));
for (int cpt=0; cpt<n ;cpt++)
{
nb=(rand()%100);
tab[cpt]=nb;
}
}
void afficher(int tab[], int n)
{
for ( int i=0;i<n;i++)
cout<<tab[i]<<" ";
}
void valmanu (int tab[], int n)
{
int a;
for (int indice=0;indice<n;indice++)
{
cout<<"vous avez rentrer "<< indice<<" chiffre"<<endl;
cin>>a;
tab[indice]=a;
}
}
void totaltab (int tab[],int n, int &total)
{
for(int indice=0;indice<n;indice++)
{
total=total+tab[indice];
}
}
void moyentab ( int tab [],int n,int total, float &moyenne )
{
moyenne=(total/(float)10);
}
void valmax (int tab [],int n,int &max)
{
max=tab[0];
for (int indice=0;indice<n;indice++)
{
if ( tab[indice]>max)
max=tab[indice];
}
}
void valmin (int tab [],int n,int &min)
{
min=tab[0];
for (int indice=0;indice<n;indice++)
{
if ( tab[indice]<min)
min=tab[indice];
}
}
int main()
{
const int NB=10;
int tab[NB];
int total=0;
float moyenne;
int max ;
int min;
int choix;
cout<<"tableau aleatoir tapez 1 "<<endl;
cout<<"tableau manuel tapez 2"<<endl;
cout<<"une autre touche pour quitter"<<endl;
cin>> choix;
switch (choix)
{
case 1:
random(tab, NB);
afficher(tab, NB);
cout<<endl;
totaltab (tab, NB ,total );
cout<<"la somme est egale a "<<total<<endl;
moyentab ( tab, NB, total, moyenne );
cout<<"la moyenne est " <<moyenne<<endl ;
valmax ( tab , NB, max);
cout<<"le max est " <<max<<endl;
valmin ( tab , NB, min);
cout <<"le min est " <<min<<endl;
break;
case 2 :
valmanu (tab, NB) ;
afficher(tab, NB);
cout<<endl;
moyentab ( tab, NB, total, moyenne );
cout<<"la moyenne est " <<moyenne<<endl ;
valmax ( tab , NB, max);
cout<<"le max est " <<max<<endl;
valmin ( tab , NB, min);
cout <<"le min est " <<min<<endl;
break;
default: cout<< " quitter " ;
}