\title{�tat civil}
\language{fr}
\author{Mathieu Cl�ment-Ziza}
\email{clementm@necker.fr}

\text{C=C_etat_civil}


\text{code_celibataire=randitem(c�libataire, mari�(e))}

\text{code_etat1=\code_celibataire issametext c�libataire ? Mademoiselle : Madame}
\text{code_etat2=\code_celibataire issametext c�libataire ? Madame : Mademoiselle}

\text{code_oui1=randitem(Oui,OUI)}
\text{faux_oui1=\code_oui1 issamecase Oui ? OUI : Oui}
\text{code_oui2=randitem(Oui,OUI)}
\text{nom=randitem(Trucmuche,Trucmachin)}

<!-- Code C de l'�nonc� -->
\text{code_c= <pre style="background-color:#F0FFFF; color:red;">
#include&#60;stdio.h>
#include&#60;string.h>

int main(void)
{
   char reponse1[4];
   char reponse2[4];
   char etat[14];
   char nom[30];
   printf("�tes-vous de sexe masculin ? ");
   scanf("%s",reponse1);
   if (strcmp(reponse1,"oui") == 0 || strcmp(reponse1,"\code_oui1") == 0)
      strcpy(etat,"Monsieur");
   else
   {
      printf("�tes-vous \code_celibataire ? ");
      scanf("%s",reponse2);
      if (strcmp(reponse2,"oui")==0 || strcmp(reponse2,"\code_oui2")==0)
         strcpy(etat,"\code_etat1");
      else
         strcpy(etat,"\code_etat2");
   }
   printf("Bonjour %s\n",etat);
   printf("Quel est votre nom ? ");
   scanf("%s",nom);
   printf("Au revoir %s ",etat);
   puts(nom);
   return 0;
}
</pre>
}

<!-- Code C++ de l'�nonc� -->
\text{code_cpp= <pre style="background-color:#F0FFFF; color:red;">
#include &#60;iostream>
#include &#60;string>
using namespace std;

int main(void) {
    string reponse1;
    string reponse2;
    string etat;
    string nom;
    cout << "�tes-vous de sexe masculin ? ";
    cin >> reponse1;
    if (reponse1 == "oui" or reponse1 == "\code_oui1") {
        etat = "Monsieur";
    } else {
        cout << "�tes-vous \code_celibataire ? ";
        cin >> reponse2;
        if ( reponse2 == "oui" or reponse2 == "\code_oui2")
            etat = "\code_etat1";
        else
            etat = "\code_etat2";
    }
    cout << "Bonjour: " << etat << endl;
    cout << "Quel est votre nom ? ";
    cin >> nom;
    cout << "Au revoir " << etat << " " nom << endl;
    return 0;
}
</pre>
}

<!-- algorithme-->
\text{algo= <pre style="background-color:#F0FFFF; color:red">

<b>DEBUT DE PROGRAMME</b>

   Afficher ("�tes-vous de sexe masculin")
   <b>SI</b> reponse est "oui" OU "\code_oui1"
       Copier la cha�ne "Monsieur" dans etat
   <b>SINON</b>
       Afficher ("�tes-vous \code_celibataire ? ")
       <b>SI</b> r�ponse est "oui" OU "\code_oui2"
           Copier la cha�ne "\code_etat1" dans etat
       <b>SINON </b>
           Copier la cha�ne "\code_etat2" dans etat
   <b>Fin SINON</b>

   Afficher ("Bonjour [etat]")
   Afficher ("Quel est votre nom ?")
   Afficher ("Au revoir [etat] [nom]")

<b>FIN DE PROGRAMME</b>
</pre>
}

<!-- matrice des choix possible -->
\matrix{M=non,non,\nom
non,NON,\nom
non,oui,\nom
non,Oui,\nom
non,OUI,\nom
NON,non,\nom
NON,NON,\nom
NON,oui,\nom
NON,Oui,\nom
NON,OUI,\nom
\code_oui1,\nom,0
oui,\nom,0
\faux_oui1,non,\nom
\faux_oui1,NON,\nom
\faux_oui1,oui,\nom
\faux_oui1,Oui,\nom
\faux_oui1,OUI,\nom}

<!-- M�lange des lignes de M -->
\text{\rows_entree=shuffle(rows(\M))}

\matrix{entree=\M[\rows_entree[1];]}
\matrix{sortie=wims( exec bioinfo  \C \code_oui1 \code_oui2  \code_etat1 \code_etat2 \code_celibataire \entree[1;1] \entree[1;2] \entree[1;3] )}


<!-- Il faut choisir le deuxi�me choix de fa�on � ce qu'il soit diff�rent du premier -->
\text{ok=0}
\text{i=2}
\while{\ok < 1}{
        \matrix{temp=\M[\rows_entree[\i];]}
        \text{out=wims( exec bioinfo  \C \code_oui1 \code_oui2 \code_etat1 \code_etat2 \code_celibataire \temp[1;1] \temp[1;2] \temp[1;3] )}
        \if {\out notsametext \sortie[1;]}{
                \integer{ok=\ok+1}
                \matrix{sortie=\sortie[1;];\out}
                \matrix{entree=\entree[1;];\temp[1;]}
        }
        \integer{i=\i+1}
}

<!-- Il faut choisir le 3�me choix de fa�on � ce qu'il soit diff�rent du 1er et du 2�me -->
\text{ok=0}
\while{\ok < 1}{
        \matrix{temp=\M[\rows_entree[\i];]}
        \text{out=wims( exec bioinfo  \C \code_oui1 \code_oui2 \code_etat1 \code_etat2 \code_celibataire \temp[1;1] \temp[1;2] \temp[1;3] )}
        \if {\out notsametext \sortie[1;] and \out <> \sortie[2;]}{
                \integer{ok=\ok+1}
                \matrix{sortie=\sortie[1;];\sortie[2;];\out}
                \matrix{entree=\entree[1;];\entree[2;];\temp[1;]}

        }
        \integer{i=\i+1}
}

<!-- D�termination au hasard de la bonne combinaison parmi les trois s�lectionn�es au hasard -->
\integer{solution=random(1..3)}

<!-- Gestion de l'enonc�-->
\text{enonce = <b>\entree[\solution;1]</b>}
\text{enonce = \enonce puis <b>\entree[\solution;2]</b>}
\text{enonce = \entree[\solution;3]!=0 ? \enonce et enfin <b>\entree[\solution;3]</b>}



\text{code=randitem(\algo,\code_c,\code_cpp)}
\text{code=\confparm2 issametext algo?\algo}
\text{code=\confparm2 issametext code?\code_c}
\text{code=\confparm2 issametext code_cpp?\code_cpp}

<!-- Affichage-->
\statement{
<!-- Enonc�-->
<p>Lors de l'ex�cution de ce programme, par saisie clavier,
l'utilisateur a r�pondu successivement \enonce.
Quels seront les affichages � l'�cran?

<!-- Tableau : � gauche le code C, � droite le QCM -->
</p>
        <table border="0" align="center">
                <tr>
                        <td>
                                <!-- Affichage du Code C -->
                                \special{expandlines \code}
                        </td>

                                <!-- Mis en forme html du QCM -->
                        <td>
                                <table align="center" border="1">
                                        <tr>
                                                <td>
                                                        \embed{reply1,1}
                                                </td>
                                                <td>
                                                        <pre>\sortie[1;]</pre>
                                                </td>
                                        </tr>

                                        <tr>
                                                <td>
                                                        \embed{reply1,2}
                                                </td>
                                                <td>
                                                        <pre>\sortie[2;]</pre>
                                                </td>
                                        </tr>

                                        <tr>
                                                <td>
                                                        \embed{reply1,3}
                                                </td>
                                                <td>
                                                        <pre>\sortie[3;]</pre>
                                                </td>
                                        </tr>
                                </table>
                        </td>

                </tr>
        </table>
}

\answer{}{\solution;A,B,C}{type=click}