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
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct Personne Personne;
struct Personne
{
char nom[100];
char prenom[100];
char adresse[1000];
int age;
int garcon; // Booléen : 1 = garçon, 0 = fille
};
int main()
{
int i=0;
Personne joueurs[2];
for (i=0 ; i<= 1 ; i++ )
{
printf("\nEntrer le nom du joueur %d: " , i+1);
scanf("%s" , joueurs[i].nom);
printf("\nEntrer le prenom du joueur %d: " , i+1);
scanf("%s" , joueurs[i].prenom);
printf("\nEntrer l'adresse du joueur %d: " , i+1);
fgets(joueurs[i].adresse, 1000, stdin);
printf("\nEntrer l'age du joueurs %d: " , i+1);
scanf("%d" , &joueurs[i].age);
printf("\nSi le joueur%d est un garcon tapez 1, sinon tapez 0: ", i+1);
scanf("%d" , &joueurs[i].garcon);
}
for (i=0 ; i<= 1 ; i++)
{
printf("\nDonnees du joueur %d:\n" , i+1);
printf("%s\n" , &joueurs[i].nom);
printf("%s\n" , &joueurs[i].prenom);
printf("%s\n" , &joueurs[i].adresse);
printf("%d ans\n" , joueurs[i].age);
if(joueurs[i].garcon == 1)
printf("Sexe: Garcon\n");
else(printf("Sexe: Fille\n"));
}
} |
Partager