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
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
ERREUR DE POINTEURERREUR DE POINTEUR par africanwinners
Cliquez pour lire la suite par africanwinners CLISTCTRLCLISTCTRL par dorras7
Cliquez pour lire la suite par dorras7
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|