Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct Participant part;
- struct Participant{
- char nomPart[20],prenomPart[20];
- int numCarte,dej,din,hotel,typehotel,fact;
- };
- int calcFact(int a,int b,int c){
- int x=0;
- if (a==1) x=x+15;
- if (b==1) x=x+35;
- if (c==1) x=x+75;
- if (c==2) x=x+100;
- return x;
- }
- part ajoutPart(int i){
- part E;
- printf("\n--Entree de donnes--\n");
- printf("Tapez le numero de ta carte d'identitee: ");
- scanf("%d",&E.numCarte);
- printf("Nom: ");
- scanf(" %s",E.nomPart);
- printf("Prenom: ");
- scanf(" %s",E.prenomPart);
- do{
- printf("Do you want to reserve for lunch? (0. No 1. Yes): ");
- scanf("%d",&E.dej);
- }while((E.dej!=0)&&(E.dej!=1));
- do{
- printf("Do you want to reserve for dinner? (0. No 1. Yes): ");
- scanf("%d",&E.din);
- }while((E.din!=0)&&(E.din!=1));
- do{
- printf("Do you want to reserve for a hotel room? (0. No 1. Yes): ");
- scanf("%d",&E.hotel);
- }while((E.hotel!=0)&&(E.hotel!=1));
- if (E.hotel==1){
- do{
- printf("Quel hotel? (1. 4 stars 2. 5 stars): ");
- scanf("%d",&E.typehotel);
- }while((E.typehotel!=1)&&(E.typehotel!=2));
- }
- E.fact=calcFact(E.dej,E.din,E.typehotel);
- return E;
- }
- void affiche(part PTAB[50],int n,int x){
- int i;
- part E;
- for(i=0;i<=n;i++){
- E=PTAB[i];
- if(x==0){
- printf("\n--Participant num %d --\n",i+1);
- printf("Num CIN: %d\n",E.numCarte);
- printf("Nom: %s\n",E.nomPart);
- printf("Prenom: %s\n",E.prenomPart);
- printf("Dej: %d\n",E.dej);
- printf("Din: %d\n",E.din);
- printf("Hotel: %d\n",E.hotel);
- if (E.hotel==1) printf("Type hotel: %d\n",E.typehotel);
- getch();
- printf("Facture: %d\n",E.fact);
- }
- else{
- if(x==E.typehotel){
- printf("\n--Participant num %d --\n",i+1);
- printf("Num CIN: %d\n",E.numCarte);
- printf("Nom: %s\n",E.nomPart);
- printf("Prenom: %s\n",E.prenomPart);
- printf("Dej: %d\n",E.dej);
- printf("Din: %d\n",E.din);
- printf("Hotel: %d\n",E.hotel);
- if (E.hotel==1) printf("Type hotel: %d\n",E.typehotel);
- getch();
- }
- }
- }
- printf("\n--Heading back to the main menu--\n");
- }
- void affichePart(part PTAB[50],int n){
- int C;
- do{
- printf("Afficher quoi exactement? (1. Tous les participants sans aucun critere, 2. Les participants qui ont choisi de reserver un hotel 4 etoiles, 3. Les participants qui ont choisi de rΓ©server un hotel 5 etoiles, 0. Retourner au menu principal): ");
- scanf("%d",&C);
- switch (C){
- case 1:{
- affiche(PTAB,n,0);
- break;
- }
- case 2:{
- affiche(PTAB,n,1);
- break;
- }
- case 3:{
- affiche(PTAB,n,2);
- break;
- }
- }
- }while(C!=0);
- printf("\n--Heading back to the menu--\n");
- getch();
- }
- part suppPart(part PTAB[50],int n){
- int CIN,i,j;
- part E;
- printf("\n--Suppression d'un participant--\n");
- printf("CIN de participant a supprimier: ");
- scanf("%d",&CIN);
- for(i=0;i<=n;i++){
- E=PTAB[i];
- if (CIN==E.numCarte) j=i;
- }
- for(i=j;i<=n;i++){
- PTAB[i]=PTAB[i+1];
- }
- return;
- }
- void main(){
- int Choix,i=-1;
- part Particip[50];
- do{
- printf("Choix: (1. Ajouter un participant 2. Liste d'affichages possibles 3. Supprimer un participant 0. Exit): \n");
- scanf("%d",&Choix);
- switch (Choix){
- case 1:{
- i++;
- Particip[i]=ajoutPart(i);
- break;
- }
- case 2:{
- affichePart(Particip,i);
- break;
- }
- case 3:{
- suppPart(Particip,i);
- i--;
- break;
- }
- default: {
- printf("Bye!");
- getch();
- }
- }
- }while(Choix!=0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement