1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
//---------------------------------------------------------------------------
#include <stdio.h>
#pragma hdrstop
#include <tchar.h>
//---------------------------------------------------------------------------
#pragma argsused
struct ageequipe{char nom[50] ; int age;} ;
struct ageequipe *equipe;
struct ageequipe *index[10];
int valeur = 0 ;
void A()
{
if(valeur<10)
{
printf("Entrez le nom du joueur %d :", ++valeur);
scanf("%s",equipe[valeur-1].nom);
printf("Entrez l'age du joueur %d :",valeur);
scanf("%d",&equipe[valeur-1].age);
}else
{
printf("\nIl y a trop de joueur\n\n\n");
}
}
void I()
void L()
{
int i;
for (i = 0; i < valeur; i++)
{
printf(" Joueur %d\n",i+1);
printf(" Nom: %s\n",equipe[i].nom);
printf(" Age: %d ans\n",equipe[i].age);
}
}
void S ()
{
printf("\n\n");
printf("\t~~ Merci et a bientot ~~");
getchar();
// Effacer l'écran:
// system("cls");
}
int _tmain(int argc, _TCHAR* argv[])
{ char choix;
equipe=NULL;
do
{
fflush(stdin);
printf("Appuyez sur\n");
printf(" A pour ajouter\n");
printf(" L pour lister\n");
printf(" I pour trier par Index\n");
printf(" S pour quitter\n");
printf("Entrez votre choix: ");
scanf("%c",&choix);
if (choix=='A')
{
if(equipe==NULL)
{
equipe=malloc(sizeof(struct ageequipe)*10);
A();
}else
A();
}
else if (choix=='L')
{
L();
}else if (choix=='S')
{
S(&equipe);
}
} while((choix=='A')||(choix=='L')||(choix=='G'));
free(equipe);
getchar();
return 0;
} |