Skip to content
Snippets Groups Projects
etat_civil.oef 5.69 KiB
\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é)}

<!-- Il faut que le source soit logique en fonction de la question 2 (célibataire ou marié) -->
\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=\confparm2 issametext algo?\algo:randitem(\algo,\code_c)}
\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}