begin process at 2012 02 12 05:02:51
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Base de données

 > BANQUE

BANQUE


 Information sur la source

Note :
3 / 10 - par 1 personne
3,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Base de données Niveau :Débutant Date de création :31/07/2001 Date de mise à jour :25/12/2001 23:11:13 Vu :8 049

Auteur : Kreator

Ecrire un message privé
Site perso
Commentaire sur cette source (1)
Ajouter un commentaire et/ou une note

 Description

Gérer un tableau, trier, afficher, opération sur les chaînes de caracteres

Source

  • // kReAtoR
  • #include <conio.h>
  • #include <stdio.h>
  • #include <alloc.h>
  • #include <string.h>
  • #define taille 10
  • typedef struct{
  • char *nom;
  • int ref;
  • int nbr;
  • }article;
  • void main()
  • {
  • int nbr_art=0;
  • int i,j=0,rep,test;
  • char *elmnt_suppr, *elmnt_modif;
  • article t[taille],t2[taille],mem;
  • char rep_2;
  • for(i=0;i<taille;i++)
  • {
  • t[i].nom=(char*)malloc(sizeof(char*));
  • t2[i].nom=(char*)malloc(sizeof(char*));
  • }
  • elmnt_suppr=(char*)malloc(sizeof(char*));
  • elmnt_modif=(char*)malloc(sizeof(char*));
  • mem.nom=(char*)malloc(sizeof(char*));
  • MENU:
  • textcolor(LIGHTGREEN);
  • textbackground(BLACK);
  • clrscr();
  • cprintf("\n\r +------------------------------------------------------------+\n\r");
  • cprintf(" | 1 -> Afficher l'etat des element du magasin |\n\r");
  • cprintf(" | 2 -> Supprimer un element dans le magasin |\n\r");
  • cprintf(" | 3 -> Ajouter un elements dans le magasin |\n\r");
  • cprintf(" | 4 -> Modifier le contenu d'un element |\n\r");
  • cprintf(" | 5 -> Rechercher le nombre d'element inferieur a 5 |\n\r");
  • cprintf(" | 6 -> Informations sur un element particulier |\n\r");
  • cprintf(" +-+--------------------------------------------------------+-+\n\r");
  • cprintf(" | 0 -> Quitte le programme |\n\r");
  • cprintf(" +--------------------------------------------------------+\n\n\r\r");
  • cprintf("Votre choix ? ");
  • scanf(" %d",&rep);
  • if(rep==1){goto LBL_1;}
  • if(rep==2){goto LBL_2;}
  • if(rep==3){goto LBL_3;}
  • if(rep==4){goto LBL_4;}
  • if(rep==5){goto LBL_5;}
  • if(rep==6){goto LBL_6;}
  • if(rep==0){goto END;}
  • LBL_1:
  • if(nbr_art==0)
  • {
  • textcolor(WHITE);
  • clrscr();
  • gotoxy(20,10);
  • cprintf("+---------------------------------+\n\r");
  • gotoxy(20,11);
  • cprintf("| Vous n'avez rien en stock |\n\r");
  • gotoxy(20,12);
  • cprintf("+---------------------------------+\n\r");
  • getch();
  • goto MENU;
  • }
  • clrscr();
  • cprintf(" Nom: | Reference: | Stock(s):\n\r");
  • cprintf("----------------------+-----------------------+----------\n\r");
  • for(i=0;i<nbr_art;i++)
  • {
  • gotoxy(2,i+3);
  • printf(" %s",t[i].nom);
  • gotoxy(25,i+3);
  • printf(" %d",t[i].ref);
  • gotoxy(49,i+3);
  • printf(" %d",t[i].nbr);
  • getch();
  • }
  • getch();
  • goto MENU;
  • LBL_2:
  • clrscr();
  • if(nbr_art==0)
  • {
  • goto LBL_1;
  • }
  • cprintf("Entrer le nom de l'element a supprimer: \n\r");
  • scanf(" %s",elmnt_suppr);
  • for(i=0;i<=nbr_art;i++)
  • {
  • test=strcmp(t[i].nom,elmnt_suppr);
  • if(i>=nbr_art)
  • {goto LBL_1;}
  • if(test==0)
  • {
  • for(j=i;j<=nbr_art;j++)
  • {
  • t[j]=t[j+1];
  • }
  • t[nbr_art-1]=t[nbr_art];
  • nbr_art--;
  • cprintf("Element supprime avec succes.\n\r");
  • }
  • }
  • cprintf("Appuyez sur une touche pour revenir au menu.\n\r");
  • getch();
  • goto MENU;
  • LBL_3:
  • clrscr();
  • do
  • {
  • cprintf("Nom de l'element: ");
  • scanf(" %s",t[nbr_art].nom);
  • for(i=0;i<=nbr_art;i++)
  • {
  • for(i=0;i<=nbr_art;i++)
  • {
  • test=strcmp(t[j].nom,t[i].nom);
  • if(i!=j && test==0)
  • {
  • cprintf("\n\rCet element est deja present.\n\r");
  • textcolor(YELLOW);cprintf("i");
  • textcolor(GREEN);cprintf("ncrementer ou ");
  • textcolor(YELLOW);cprintf("c");
  • textcolor(GREEN);cprintf("reer un nouvel article ? ");
  • scanf(" %c",&rep_2);
  • if(rep_2=='c'){textcolor(LIGHTGREEN);goto LBL_3;}
  • if(rep_2=='i')
  • {
  • t[i].nbr++;
  • }
  • }
  • }
  • }
  • if(rep_2!='i')
  • {
  • cprintf("Reference: ");
  • scanf(" %d",&t[nbr_art].ref);
  • cprintf("Nombre d'element de ce type: ");
  • scanf(" %d",&t[nbr_art].nbr);
  • nbr_art++;
  • for(i=0;i<nbr_art;i++)
  • {
  • for(j=i;j<nbr_art;j++)
  • {
  • test=strcmp(t[j].nom,t[i].nom);
  • if(test<0)
  • {
  • mem=t[i];
  • t[i]=t[j];
  • t[j]=mem;
  • i--;
  • }
  • }
  • }
  • }
  • cprintf("\n\rEncore un article ? ");
  • scanf(" %c",&rep_2);
  • cprintf("\n\r\n\r");
  • }while(nbr_art<taille && rep_2=='o');
  • getch();
  • goto MENU;
  • LBL_4:
  • textcolor(WHITE);
  • clrscr();
  • if(nbr_art==0)
  • {
  • goto LBL_1;
  • }
  • cprintf("Entrer le nom de l'element a modifier:\n\r");
  • scanf(" %s",elmnt_modif);
  • for(i=0;i<nbr_art;i++)
  • {
  • test=strcmp(t[i].nom,elmnt_modif);
  • if(i>nbr_art && test!=0)
  • {
  • cprintf("Votre elemnet n'a pas ete trouve.\n\r");
  • }
  • if(test==0)
  • {cprintf("Nombre en stock: %d , entrer la nouvelle quantite: ",t[i].nbr);
  • scanf(" %d",&t[i].nbr);
  • }
  • }
  • cprintf("\n\rAppuyer sur une touche pour revenir au menu.\n\r");
  • getch();
  • goto MENU;
  • LBL_5:
  • clrscr();
  • if(nbr_art==0)
  • {
  • goto LBL_1;
  • }
  • textcolor(YELLOW);
  • cprintf("Liste des elements dont le stock est inferieur a 5:\n\r");
  • cprintf("---------------------------------------------------\n\r");
  • for(i=0;i<nbr_art;i++)
  • {
  • if(t[i].nbr<5)
  • {
  • t2[i]=t[i];
  • textcolor(WHITE);
  • cprintf("Nom: %-20s Reference: %-10d Stock: %-15d \n\r",t2[i].nom,t2[i].ref,t2[i].nbr);
  • getch();
  • }
  • }
  • getch();
  • goto MENU;
  • LBL_6:
  • textcolor(WHITE);
  • clrscr();
  • if(nbr_art==0)
  • {
  • goto LBL_1;
  • }
  • cprintf("Entrer le nom de l'element:\n\r");
  • scanf(" %s",elmnt_modif);
  • for(i=0;i<nbr_art;i++)
  • {
  • test=strcmp(t[i].nom,elmnt_modif);
  • if(test==0)
  • {
  • cprintf("\n\r+--------------------------------------------\n\r");
  • cprintf("|Nom: %-30s\n\r",t[i].nom);
  • cprintf("|Reference: %-30d\n\r",t[i].ref);
  • cprintf("|Stock: %-30d\n\r",t[i].nbr);
  • cprintf("+--------------------------------------------\n\r");
  • }
  • }
  • if(test!=0)
  • {cprintf("Element non present.");}
  • cprintf("\n\r\n\rAppuyer sur une touche pour revenir au menu.\n\r");
  • getch();
  • goto MENU;
  • END:
  • textcolor(YELLOW);
  • printf("\n");
  • cprintf("Le programme a ete interrompu. Appuyez sur une touche pour le quitter.");
  • getch();
  • }
// kReAtoR	

#include <conio.h>
#include <stdio.h>
#include <alloc.h>
#include <string.h>
#define taille 10

typedef struct{
char *nom;
int ref;
int nbr;
}article;

void main()

{
int nbr_art=0;
int i,j=0,rep,test;
char *elmnt_suppr, *elmnt_modif;
article t[taille],t2[taille],mem;
char rep_2;

for(i=0;i<taille;i++)
{
t[i].nom=(char*)malloc(sizeof(char*));
t2[i].nom=(char*)malloc(sizeof(char*));
}
elmnt_suppr=(char*)malloc(sizeof(char*));
elmnt_modif=(char*)malloc(sizeof(char*));
mem.nom=(char*)malloc(sizeof(char*));

MENU:
textcolor(LIGHTGREEN);
textbackground(BLACK);
clrscr();
cprintf("\n\r    +------------------------------------------------------------+\n\r");
cprintf("    | 1 -> Afficher l'etat des element du magasin                |\n\r");
cprintf("    | 2 -> Supprimer un element dans le magasin                  |\n\r");
cprintf("    | 3 -> Ajouter un elements dans le magasin                   |\n\r");
cprintf("    | 4 -> Modifier le contenu d'un element                      |\n\r");
cprintf("    | 5 -> Rechercher le nombre d'element inferieur a 5          |\n\r");
cprintf("    | 6 -> Informations sur un element particulier               |\n\r");
cprintf("    +-+--------------------------------------------------------+-+\n\r");
cprintf("      |   0  ->  Quitte le programme                           |\n\r");
cprintf("      +--------------------------------------------------------+\n\n\r\r");

cprintf("Votre choix ? ");
scanf(" %d",&rep);
if(rep==1){goto LBL_1;}
if(rep==2){goto LBL_2;}
if(rep==3){goto LBL_3;}
if(rep==4){goto LBL_4;}
if(rep==5){goto LBL_5;}
if(rep==6){goto LBL_6;}
if(rep==0){goto END;}



LBL_1:
if(nbr_art==0)
	{
   textcolor(WHITE);
   clrscr();
   gotoxy(20,10);
	cprintf("+---------------------------------+\n\r");
   gotoxy(20,11);
   cprintf("|    Vous n'avez rien en stock    |\n\r");
   gotoxy(20,12);
   cprintf("+---------------------------------+\n\r");
   getch();
   goto MENU;
   }
clrscr();
cprintf(" Nom:                 | Reference:            | Stock(s):\n\r");
cprintf("----------------------+-----------------------+----------\n\r");
for(i=0;i<nbr_art;i++)
	{
   gotoxy(2,i+3);
   printf(" %s",t[i].nom);
   gotoxy(25,i+3);
   printf(" %d",t[i].ref);
   gotoxy(49,i+3);
   printf(" %d",t[i].nbr);
   getch();
   }
getch();
goto MENU;





LBL_2:
clrscr();
if(nbr_art==0)
	{
   goto LBL_1;
   }
cprintf("Entrer le nom de l'element a supprimer: \n\r");
scanf(" %s",elmnt_suppr);
for(i=0;i<=nbr_art;i++)
	{
   test=strcmp(t[i].nom,elmnt_suppr);
   if(i>=nbr_art)
   	{goto LBL_1;}
   if(test==0)
   	{
		for(j=i;j<=nbr_art;j++)
      	{
	      t[j]=t[j+1];
         }
      t[nbr_art-1]=t[nbr_art];
      nbr_art--;
      cprintf("Element supprime avec succes.\n\r");
      }
   }
cprintf("Appuyez sur une touche pour revenir au menu.\n\r");
getch();
goto MENU;



LBL_3:
clrscr();
do
	{
   cprintf("Nom de l'element: ");
   scanf(" %s",t[nbr_art].nom);
   for(i=0;i<=nbr_art;i++)
   	{
	   for(i=0;i<=nbr_art;i++)
   		{
         test=strcmp(t[j].nom,t[i].nom);
         if(i!=j && test==0)
         	{
            cprintf("\n\rCet element est deja present.\n\r");
				textcolor(YELLOW);cprintf("i");
            textcolor(GREEN);cprintf("ncrementer ou ");
            textcolor(YELLOW);cprintf("c");
            textcolor(GREEN);cprintf("reer un nouvel article ? ");
            scanf(" %c",&rep_2);
            if(rep_2=='c'){textcolor(LIGHTGREEN);goto LBL_3;}
            if(rep_2=='i')
            	{
               t[i].nbr++;
               }
			   }
			}
		}
	if(rep_2!='i')
		{
		cprintf("Reference: ");
		scanf(" %d",&t[nbr_art].ref);
		cprintf("Nombre d'element de ce type: ");
		scanf(" %d",&t[nbr_art].nbr);
	   nbr_art++;
	 	for(i=0;i<nbr_art;i++)
			{
		   for(j=i;j<nbr_art;j++)
			  	{
	         test=strcmp(t[j].nom,t[i].nom);
	         if(test<0)
			     	{
		         mem=t[i];
		         t[i]=t[j];
		         t[j]=mem;
		         i--;
		         }
		      }
         }
      }
   cprintf("\n\rEncore un article ? ");
   scanf(" %c",&rep_2);
   cprintf("\n\r\n\r");
   }while(nbr_art<taille && rep_2=='o');
getch();
goto MENU;



LBL_4:
textcolor(WHITE);
clrscr();
if(nbr_art==0)
	{
   goto LBL_1;
   }
cprintf("Entrer le nom de l'element a modifier:\n\r");
scanf(" %s",elmnt_modif);
for(i=0;i<nbr_art;i++)
	{
   test=strcmp(t[i].nom,elmnt_modif);
   if(i>nbr_art && test!=0)
   	{
      cprintf("Votre elemnet n'a pas ete trouve.\n\r");
      }
   if(test==0)
   	{cprintf("Nombre en stock: %d , entrer la nouvelle quantite: ",t[i].nbr);
      scanf(" %d",&t[i].nbr);
      }
   }
cprintf("\n\rAppuyer sur une touche pour revenir au menu.\n\r");
getch();
goto MENU;



LBL_5:
clrscr();
if(nbr_art==0)
	{
   goto LBL_1;
   }
textcolor(YELLOW);
cprintf("Liste des elements dont le stock est inferieur a 5:\n\r");
cprintf("---------------------------------------------------\n\r");
for(i=0;i<nbr_art;i++)
	{
   if(t[i].nbr<5)
   	{
      t2[i]=t[i];
      textcolor(WHITE);
      cprintf("Nom: %-20s    Reference: %-10d    Stock: %-15d \n\r",t2[i].nom,t2[i].ref,t2[i].nbr);
      getch();
      }
   }
getch();
goto MENU;



LBL_6:
textcolor(WHITE);
clrscr();
if(nbr_art==0)
	{
   goto LBL_1;
   }
cprintf("Entrer le nom de l'element:\n\r");
scanf(" %s",elmnt_modif);
for(i=0;i<nbr_art;i++)
	{
   test=strcmp(t[i].nom,elmnt_modif);
   if(test==0)
   	{
      cprintf("\n\r+--------------------------------------------\n\r");
      cprintf("|Nom: %-30s\n\r",t[i].nom);
      cprintf("|Reference: %-30d\n\r",t[i].ref);
      cprintf("|Stock: %-30d\n\r",t[i].nbr);
      cprintf("+--------------------------------------------\n\r");
		}
   }
if(test!=0)
  	{cprintf("Element non present.");}

cprintf("\n\r\n\rAppuyer sur une touche pour revenir au menu.\n\r");
getch();
goto MENU;


END:
textcolor(YELLOW);
printf("\n");
cprintf("Le programme a ete interrompu. Appuyez sur une touche pour le quitter.");
getch();
}



 

 Conclusion

Tres simplifié, que des "LABEL" !!! A la barbare !!!!


 Sources du même auteur

MOTUS
Source avec Zip COMPRESSION HUFFMAN
Source avec Zip IO.SYS
Source avec Zip CHEAT MODE POUR ALERT ROUGE 2
Source avec Zip PIX ANIM

 Sources de la même categorie

GESTION DE FICHIER ET DOSSIER + AUTRES par shinji63
Source avec une capture CONVERTISSEUR par smartties
Source avec Zip CREATION D'UN FICHIER DBF (EN C) par Stanel
Source avec Zip STRUCTURE DES FICHIERS DBF par Stanel
Source avec Zip Source avec une capture GESTION DES ENTREES/ SORTIES AVEC CODEBARRE par YvaddavY

Commentaires et avis

Commentaire de mythic_kruger le 07/07/2005 00:07:59

Pourquoi pas un switch alors !?!...

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,484 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales