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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
| #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct
{
char Modele[10];
char identification[10];
int Kilometre;
char etat[3];
}MAGASIN;
int main()
{
MAGASIN M[6];
strcpy(M[0].Modele,"yamaha");
strcpy(M[0].identification,"YAM80");
M[0].Kilometre=1410;
strcpy(M[0].etat,"oui");
strcpy(M[1].Modele,"piaggo");
strcpy(M[1].identification,"PIA125");
M[1].Kilometre=1220;
strcpy(M[1].etat,"non");
strcpy(M[2].Modele,"mbk");
strcpy(M[2].identification,"MBK250");
M[2].Kilometre=450;
strcpy(M[2].etat,"non");
strcpy(M[3].Modele,"gilera");
strcpy(M[3].identification,"GIL80");
M[3].Kilometre=740;
strcpy(M[3].etat,"oui");
strcpy(M[4].Modele,"honda");
strcpy(M[4].identification,"HON250");
M[4].Kilometre=1800;
strcpy(M[4].etat,"oui");
strcpy(M[5].Modele,"suzuki");
strcpy(M[5].identification,"SUZ80");
M[5].Kilometre=50;
strcpy(M[5].etat,"oui");
int ch,i,s,sl,sd,K;
char ID;
//M.Kilometre
do{
printf("1- Louer un scooter \n");
printf("2- Retour d un scooter \n");
printf("3- etat d un scooter \n");
printf("4- etat de parc de scooter \n");
printf("0- FIN DE PROGRAMME\n");
printf("entrez votre choix : ");
scanf("%d",&ch);
}
while((ch!=1)&&(ch!=2)&&(ch!=3)&&(ch!=4)&&(ch!=0));
do
{
switch(ch)
{
case 1:
for(i=1;i<=6;i++)
{
printf("entrez le numero de l identification ");
scanf("%s",&ID);
for(i=0;i<6;i++){
if(strcmp(M[i].identification,ID))
{
if (strcmp(M[i].etat,"oui"))
{
printf("le scooter est deja loue");
}
else
{
printf("le scooter n est pas loue");
}
}
else
{
printf("le scooter n existe pas");
}
}
/*printf("LE MODELE DE SCOOTER : ",M[i].Modele);
//scanf("%s",&);
printf("LE NUMERO D IDENTIFICATION DE SCOOTER : ",M[i].identification);
//scanf("%s",&);
printf("LE KILOMETRAGE DE SCOOTER : ",M[i].Kilometre);
//scanf("%s",&);*/
}
break;
case 2:
printf("entrez le numero d identification de votre modele : ");
scanf("%s",&ID);
for(i=1;i<=6;i++)
{
if (strcmp(ID,M[i].identification))
{
printf("entrez le kilometrage de votre modele : ");
scanf("%d",&K);
M[i].Kilometre=K;
strcpy(M[i].etat,"non");
printf("le scooter n %s retourne au depot",M[i].identification);
}
else
{
printf("le scooter n existe pas");
}
}
break;
case 3:
printf("entrez le numero d identification de votre modele : ");
scanf("%s",&ID);
for(i=1;i<=6;i++)
{
if (strcmp(M[i].identification,ID))
{
printf("l etat de scooter est loue");
printf("le scooter : %s",M[i].Modele);
printf("le n identification : %s",M[i].identification);
printf("la distance en kilometre : %d",M[i].Kilometre);
printf("l etat de scooter : %s",M[i].etat);
}
else
{
printf("l etat de scooter n est loue ");
}
}
break;
case 4:
for(i=1;i<=6;i++)
{
s=s+M[i];
if (strcmp(M[i].etat,"oui"))
{
sl=sl+M[i].Modele;
printf("le nombre de scooter en location est %d et l identification est %s",sl,M[i].identificateur);
}
else
{
sd=sd+M[i];
printf("le nombre de scooter disponible est %d et l identification est %s",sd,M[i].identificateur);
}
mk=M[i].kilometre/s;
}
break;
default :
printf("FIN DE PROGRAMME");
break;
}
}
while((ch!=1)&&(ch!=2)&&(ch!=3)&&(ch!=4)&&(ch!=0));
return 0;
} |
Partager