Accueil > > > SONDAGE ELECTIONS PRESIDENTIELLES LANGAGEC
SONDAGE ELECTIONS PRESIDENTIELLES LANGAGEC
Information sur la source
Description
Utilisation de structures de fichiers: ecriture et lecture, des fonctions.
Ce programme comporte un menu de presentation, des saisies de chaines de caracteres et des lecture de chaines de caracteres. Une fonction qui evite les doublons(=redondance des personnes saisies). Une fonction statistique qui serait à améliorer. Note: 16/20.
Source
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #define LGNOM 20
- #define LGPRENOM 15
- #define LGTEL 11
- #define LGMOIS 25
- #define LGJOUR 3
- #define LGANNEE 5
- #define LGNOMCHER 20
- #define LGVERIFNOM 20
- #define LGVERIFPRENOM 15
- #define LGNOM1 20
- #define LGPRENOM1 15
- #define LGCANDIDAT 3
-
-
- int i;
- float somme=0;
-
-
- FILE *sortie;
-
- struct { char nom[LGNOM+1];
- char prenom[LGPRENOM+1];
- char jour[LGJOUR+1];
- char mois[LGMOIS+1];
- char annee[LGANNEE+1];
- char tel[LGTEL+1];
- char candidat[LGCANDIDAT+1];
- }fait;
-
- FILE *entree;
-
- char * tampon;
- char * nomfic="c:\meaux2.dat";
-
-
-
-
- void main (void)
- {
- void introduction (void);
- void menu (void);
- void saisie (void);
- void lecture (void);
- void liste (void);
- void verif (void);
- void statistique (void);
-
-
-
- clrscr();
- introduction();
- getch();
-
- clrscr();
- menu();
- getch();
-
- }
-
-
-
-
-
-
-
-
- void introduction (void)
- {
- clrscr();
- printf ("\n\n\n\n\n\n\n\n\t\t\tB I E N V E N U E.");
- getch();
- clrscr();
- printf ("\n\n\n\n\n\n\n\n\n\t\tSondage pour les ,lections pr,sidentielles.");
- getch();
- }
-
-
- void menu (void)
- {
- int n;
-
- printf ("\n\t\t\t\tMenu G,n,ral\n\n\n\n");
- printf ("\t\t1) Vous voulez vous inscrire.\n\n\n");
- printf ("\t\t2) Rechercher une personne.\n\n\n");
- printf ("\t\t3) Impression de la liste d'inscription.\n\n\n");
- printf ("\t\t4) V,rifiez si vous ^tes d,j. inscrit.\n\n\n");
- printf ("\t\t5) Stat:\n\n\n");
- printf ("\nVotre choix:");
- scanf("%d",&n);
-
- if (n==1)
- {
- clrscr();
- saisie();
- getch();
- }
-
- if (n==2)
- {
- clrscr();
- lecture();
- getch();
- }
-
- if (n==3)
- {
- clrscr();
- liste();
- getch();
- }
-
- if (n==4)
- {
- clrscr();
- verif();
- getch();
- }
-
- if(n==5)
- {
- clrscr();
- statistique();
- getch();
- }
-
- }
-
-
- void saisie (void)
- {
- sortie=fopen (nomfic,"a");
-
- printf ("Entrez un nom en MAJUSCULES lors de la saisie.");
- printf ("\n\nLaisser un nom VIDE . la fin de chaque saisie.");
- gets (tampon);
-
- while (printf ("\n\nNom:"), gets (fait.nom), strlen (fait.nom))
- {
- printf ("Pr,nom:");
- scanf ("%s",&fait.prenom);
- printf ("Jour:");
- scanf ("%s",&fait.jour);
- printf ("Mois:");
- scanf ("%s",&fait.mois);
- printf ("Ann,e:");
- scanf ("%s",&fait.annee);
- printf ("T,l,phone:");
- scanf ("%s",&fait.tel);
- printf ("Candidat LJ, JC, LP, RH, AL, NM:");
- scanf ("%s",&fait.candidat);
-
-
- fwrite (&fait, sizeof(fait), 1, sortie);
- }
- fclose (sortie);
- }
-
-
-
- void verif (void)
- {
- int intrus;
- char verifnom[LGVERIFNOM+1];
- char verifprenom[LGVERIFPRENOM+1];
- char nom1[LGNOM1+1];
- char prenom1[LGPRENOM1+1];
-
- printf ("Entrer un nom et un prenom puis le prenom et le nom . v,rifier:");
- scanf ("%s%s%s%s",&verifnom,&verifprenom,&prenom1,&nom1);
- intrus=0;
-
- entree=fopen (nomfic,"r");
-
- do
- {
- fread (&fait, sizeof(fait), 1, entree);
- if (((strcmp (verifnom, fait.nom)==0)&&(strcmp (verifprenom, fait.prenom)==0))||((strcmp (prenom1,fait.prenom)==0)&&(strcmp (nom1,fait.nom)==0)))
- intrus=1;
- }
- while ((!intrus)&&(!feof (entree)));
-
- if (intrus)
- {
- printf ("Vous ^tes d,j. inscrit.");
- }
-
- else
- {
- printf ("Inscrivez vous.");
- menu();
- }
-
- fclose (entree);
- }
-
-
-
- void lecture (void)
- {
- char nomcher[LGNOMCHER+1];
- int trouve;
-
-
- entree=fopen (nomfic,"r");
- printf ("Nom cherch,:");
- scanf ("%s",&nomcher);
- trouve=0;
-
- do
- {
- fread (&fait, sizeof(fait), 1, entree);
- if (strcmp (nomcher, fait.nom)==0)
- trouve=1;
- }
- while ((!trouve)&&(!feof (entree)));
-
- if (trouve)
- {
- printf ("prenom:%s\n",fait.prenom);
- printf ("jour:%s\n",fait.jour);
- printf ("mois:%s\n",fait.mois);
- printf ("annee:%s\n",fait.annee);
- printf ("t,l,phone:%s\n",fait.tel);
- printf ("candidat:%s\n",fait.candidat);
- }
-
- else
- printf ("Ce nom ne figure pas dans la base de donn,es.");
-
-
- fclose (entree);
- }
-
-
- void liste (void)
- {
-
- entree=fopen (nomfic,"r");
- printf ("\t\t\tListe des personnes inscrites.");
- printf ("\n\n\n\tNom\tPr,nom\tJour\tMois\tAnnee\tT,l,phone\tCandidat");
-
- while (fread (&fait, sizeof(fait), 1, entree), !feof(entree))
- {
- printf ("\n\t%s %s %s %s %s %s %s",fait.nom,fait.prenom,fait.jour,fait.mois,fait.annee,fait.tel,fait.candidat);
- }
-
- fclose (entree);
-
-
- /*printf ("Impression de la liste");
- fprintf (stdprn,"Liste des personnes inscrites");*/
- }
-
-
- void statistique (void)
- {
- float somme_LJ=0, somme_JC=0, somme_LP=0, somme_RH=0, somme_AL=0, somme_NM=0,som;
- float pourcentage_LJ, pourcentage_JC, pourcentage_LP, pourcentage_RH, pourcentage_AL, pourcentage_NM;
- entree=fopen (nomfic,"r");
-
- do
- {
- fread (&fait, sizeof (fait), 1, entree);
-
- if (fait.nom)
- {
- somme=somme+1;
- printf ("\n\t%s",fait.nom);
- printf ("\n%f",somme);
- }
-
-
- if (strcmp (fait.candidat,"LJ")==0)
- {
- somme_LJ=somme_LJ+1;
- pourcentage_LJ=(somme_LJ/somme)*100;
- printf ("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\%f",somme_LJ);
- printf ("\n%f",pourcentage_LJ);
- }
-
-
- if (strcmp (fait.candidat,"JC")==0)
- {
- somme_JC=somme_JC+1;
- pourcentage_JC=(somme_JC/somme)*100;
- printf ("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\n%f",somme_JC);
- printf ("\n%f",pourcentage_JC);
- }
-
-
- if (strcmp (fait.candidat,"LP")==0)
- {
- somme_LP=somme_LP+1;
- pourcentage_LP=(somme_LP/somme)*100;
- printf("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\n%f",somme_LP);
- printf ("\n%f",pourcentage_LP);
- }
-
- if (strcmp (fait.candidat,"RH")==0)
- {
- somme_RH=somme_RH+1;
- pourcentage_RH=(somme_RH/somme)*100;
- printf ("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\n%f",somme_RH);
- printf ("\n%f",pourcentage_RH);
- }
-
- if (strcmp (fait.candidat,"AL")==0)
- {
- somme_AL=somme_AL+1;
- pourcentage_AL=(somme_AL/somme)*100;
- printf ("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\n%f",somme_AL);
- printf ("\n%f",pourcentage_AL);
- }
-
- if (strcmp (fait.candidat,"NM")==0)
- {
- somme_NM=somme_NM+1;
- pourcentage_NM=(somme_NM/somme)*100;
- printf ("\n%s",fait.candidat);
- printf ("\t%f",somme);
- printf ("\n%f",somme_NM);
- printf ("\n%f",pourcentage_NM);
- }
-
- }
- while (!feof (entree));
-
-
- printf ("%f %f %f %f %f",somme,somme_JC,somme_LP,somme_AL,somme_NM);
- printf ("\n\tLionel Jospin Jacques Chirac Jean-Marie Le Pen");
- printf ("\n\n\t %f \t %f \t %f", pourcentage_LJ, pourcentage_JC, pourcentage_LP);
-
- printf ("\n\n\n\t Robert Hue Arlette Laguillier Noel Mamere");
- printf ("\n\n\t %f \t %f \t %f", pourcentage_RH, pourcentage_AL, pourcentage_NM);
-
- }
-
-
-
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define LGNOM 20
#define LGPRENOM 15
#define LGTEL 11
#define LGMOIS 25
#define LGJOUR 3
#define LGANNEE 5
#define LGNOMCHER 20
#define LGVERIFNOM 20
#define LGVERIFPRENOM 15
#define LGNOM1 20
#define LGPRENOM1 15
#define LGCANDIDAT 3
int i;
float somme=0;
FILE *sortie;
struct { char nom[LGNOM+1];
char prenom[LGPRENOM+1];
char jour[LGJOUR+1];
char mois[LGMOIS+1];
char annee[LGANNEE+1];
char tel[LGTEL+1];
char candidat[LGCANDIDAT+1];
}fait;
FILE *entree;
char * tampon;
char * nomfic="c:\meaux2.dat";
void main (void)
{
void introduction (void);
void menu (void);
void saisie (void);
void lecture (void);
void liste (void);
void verif (void);
void statistique (void);
clrscr();
introduction();
getch();
clrscr();
menu();
getch();
}
void introduction (void)
{
clrscr();
printf ("\n\n\n\n\n\n\n\n\t\t\tB I E N V E N U E.");
getch();
clrscr();
printf ("\n\n\n\n\n\n\n\n\n\t\tSondage pour les ,lections pr,sidentielles.");
getch();
}
void menu (void)
{
int n;
printf ("\n\t\t\t\tMenu G,n,ral\n\n\n\n");
printf ("\t\t1) Vous voulez vous inscrire.\n\n\n");
printf ("\t\t2) Rechercher une personne.\n\n\n");
printf ("\t\t3) Impression de la liste d'inscription.\n\n\n");
printf ("\t\t4) V,rifiez si vous ^tes d,j. inscrit.\n\n\n");
printf ("\t\t5) Stat:\n\n\n");
printf ("\nVotre choix:");
scanf("%d",&n);
if (n==1)
{
clrscr();
saisie();
getch();
}
if (n==2)
{
clrscr();
lecture();
getch();
}
if (n==3)
{
clrscr();
liste();
getch();
}
if (n==4)
{
clrscr();
verif();
getch();
}
if(n==5)
{
clrscr();
statistique();
getch();
}
}
void saisie (void)
{
sortie=fopen (nomfic,"a");
printf ("Entrez un nom en MAJUSCULES lors de la saisie.");
printf ("\n\nLaisser un nom VIDE . la fin de chaque saisie.");
gets (tampon);
while (printf ("\n\nNom:"), gets (fait.nom), strlen (fait.nom))
{
printf ("Pr,nom:");
scanf ("%s",&fait.prenom);
printf ("Jour:");
scanf ("%s",&fait.jour);
printf ("Mois:");
scanf ("%s",&fait.mois);
printf ("Ann,e:");
scanf ("%s",&fait.annee);
printf ("T,l,phone:");
scanf ("%s",&fait.tel);
printf ("Candidat LJ, JC, LP, RH, AL, NM:");
scanf ("%s",&fait.candidat);
fwrite (&fait, sizeof(fait), 1, sortie);
}
fclose (sortie);
}
void verif (void)
{
int intrus;
char verifnom[LGVERIFNOM+1];
char verifprenom[LGVERIFPRENOM+1];
char nom1[LGNOM1+1];
char prenom1[LGPRENOM1+1];
printf ("Entrer un nom et un prenom puis le prenom et le nom . v,rifier:");
scanf ("%s%s%s%s",&verifnom,&verifprenom,&prenom1,&nom1);
intrus=0;
entree=fopen (nomfic,"r");
do
{
fread (&fait, sizeof(fait), 1, entree);
if (((strcmp (verifnom, fait.nom)==0)&&(strcmp (verifprenom, fait.prenom)==0))||((strcmp (prenom1,fait.prenom)==0)&&(strcmp (nom1,fait.nom)==0)))
intrus=1;
}
while ((!intrus)&&(!feof (entree)));
if (intrus)
{
printf ("Vous ^tes d,j. inscrit.");
}
else
{
printf ("Inscrivez vous.");
menu();
}
fclose (entree);
}
void lecture (void)
{
char nomcher[LGNOMCHER+1];
int trouve;
entree=fopen (nomfic,"r");
printf ("Nom cherch,:");
scanf ("%s",&nomcher);
trouve=0;
do
{
fread (&fait, sizeof(fait), 1, entree);
if (strcmp (nomcher, fait.nom)==0)
trouve=1;
}
while ((!trouve)&&(!feof (entree)));
if (trouve)
{
printf ("prenom:%s\n",fait.prenom);
printf ("jour:%s\n",fait.jour);
printf ("mois:%s\n",fait.mois);
printf ("annee:%s\n",fait.annee);
printf ("t,l,phone:%s\n",fait.tel);
printf ("candidat:%s\n",fait.candidat);
}
else
printf ("Ce nom ne figure pas dans la base de donn,es.");
fclose (entree);
}
void liste (void)
{
entree=fopen (nomfic,"r");
printf ("\t\t\tListe des personnes inscrites.");
printf ("\n\n\n\tNom\tPr,nom\tJour\tMois\tAnnee\tT,l,phone\tCandidat");
while (fread (&fait, sizeof(fait), 1, entree), !feof(entree))
{
printf ("\n\t%s %s %s %s %s %s %s",fait.nom,fait.prenom,fait.jour,fait.mois,fait.annee,fait.tel,fait.candidat);
}
fclose (entree);
/*printf ("Impression de la liste");
fprintf (stdprn,"Liste des personnes inscrites");*/
}
void statistique (void)
{
float somme_LJ=0, somme_JC=0, somme_LP=0, somme_RH=0, somme_AL=0, somme_NM=0,som;
float pourcentage_LJ, pourcentage_JC, pourcentage_LP, pourcentage_RH, pourcentage_AL, pourcentage_NM;
entree=fopen (nomfic,"r");
do
{
fread (&fait, sizeof (fait), 1, entree);
if (fait.nom)
{
somme=somme+1;
printf ("\n\t%s",fait.nom);
printf ("\n%f",somme);
}
if (strcmp (fait.candidat,"LJ")==0)
{
somme_LJ=somme_LJ+1;
pourcentage_LJ=(somme_LJ/somme)*100;
printf ("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\%f",somme_LJ);
printf ("\n%f",pourcentage_LJ);
}
if (strcmp (fait.candidat,"JC")==0)
{
somme_JC=somme_JC+1;
pourcentage_JC=(somme_JC/somme)*100;
printf ("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\n%f",somme_JC);
printf ("\n%f",pourcentage_JC);
}
if (strcmp (fait.candidat,"LP")==0)
{
somme_LP=somme_LP+1;
pourcentage_LP=(somme_LP/somme)*100;
printf("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\n%f",somme_LP);
printf ("\n%f",pourcentage_LP);
}
if (strcmp (fait.candidat,"RH")==0)
{
somme_RH=somme_RH+1;
pourcentage_RH=(somme_RH/somme)*100;
printf ("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\n%f",somme_RH);
printf ("\n%f",pourcentage_RH);
}
if (strcmp (fait.candidat,"AL")==0)
{
somme_AL=somme_AL+1;
pourcentage_AL=(somme_AL/somme)*100;
printf ("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\n%f",somme_AL);
printf ("\n%f",pourcentage_AL);
}
if (strcmp (fait.candidat,"NM")==0)
{
somme_NM=somme_NM+1;
pourcentage_NM=(somme_NM/somme)*100;
printf ("\n%s",fait.candidat);
printf ("\t%f",somme);
printf ("\n%f",somme_NM);
printf ("\n%f",pourcentage_NM);
}
}
while (!feof (entree));
printf ("%f %f %f %f %f",somme,somme_JC,somme_LP,somme_AL,somme_NM);
printf ("\n\tLionel Jospin Jacques Chirac Jean-Marie Le Pen");
printf ("\n\n\t %f \t %f \t %f", pourcentage_LJ, pourcentage_JC, pourcentage_LP);
printf ("\n\n\n\t Robert Hue Arlette Laguillier Noel Mamere");
printf ("\n\n\t %f \t %f \t %f", pourcentage_RH, pourcentage_AL, pourcentage_NM);
}
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|