begin process at 2012 05 27 21:18:31
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > VIET

VIET


 Information sur la source

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

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Maths & Algorithmes Niveau :Débutant Date de création :08/10/2003 Date de mise à jour :04/11/2003 18:46:48 Vu :1 798

Auteur : Siriusgalaxie26

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

 Description

Et voici ma première source : Le traditionel théorème de VIET. Il est assez simple, il fonctionne en Win32 sous borland et Visual
Je pense avoir usé et abusé des fonctions...
Notez le moi, SVP

Source

  • //------------------------------BIBLIOTHEQUES-----------------------------------
  • #include <conio.h>
  • #include <stdio.h>
  • #include <string.h>
  • #include <math.h>
  • #include <iostream.h>
  • #include <fstream.h>
  • #include <ios.h>
  • #include <PROCESS.H>
  • //--------------------------------PROTOTYPES------------------------------------
  • void menu(void);
  • void quitter(void);
  • void erreur(void);
  • void equation(void);
  • float delta(float A,float B,float C);
  • float unesolution (float A,float B,float C,float DELTA);
  • float deuxsolutions (float A,float B,float C,float DELTA);
  • void pasdesolution (void);
  • float racine (float DELTA);
  • void operation(void);
  • void clrscr(void);
  • char* fl_char (float);
  • //--------------------------------VARIABLES-------------------------------------
  • float A,B,C,DELTA,X1,X2,X,RD;
  • float fl[30];
  • char op[100];
  • char flchar[30];
  • //--------------------------------PROGRAMME-------------------------------------
  • void main(void)
  • {
  • menu();
  • getche();
  • printf("\n\n\n\t\t\t***ERREUR FATALE DU PROGRAMME***\n");
  • getch();
  • clrscr();
  • printf("\n\n\n\t\t\t\t***TANT PIS...***\n");
  • getch();
  • clrscr();
  • quitter();
  • }
  • //-------------------------------FONCTIONS--------------------------------------
  • //---------------------------------MENU-----------------------------------------
  • void menu(void)
  • {
  • clrscr();
  • printf("\n\t***RESOLUTION D'EQUATIONS DU 2EME DEGRES ET AUTRES CALCULES***\n\n\n\t\t\t");
  • int choix=0;
  • printf("\n\n\t\t\t ****************\n");
  • printf("\t\t\t *MENU PRINCIPALE*\n");
  • printf("\t\t\t ****************\n\n\n\n");
  • printf("\t TAPEZ :\n\n\n\n");
  • printf("\t\t1\t POUR\t RESOUDRE UNE EQUATION DU 2eme DEGRE\n\n");
  • printf("\t\t2\t POUR\t QUITTER\n\n\n");
  • printf("\t CHOIX : ");
  • scanf("%d",&choix);
  • switch(choix)
  • {
  • case 1 : equation();
  • break;
  • case 2 : quitter();
  • break;
  • default : erreur();
  • }
  • }
  • //-------------------------------EQUATION---------------------------------------
  • void equation(void)
  • {
  • clrscr();
  • printf("\n\n\t\t***ENTREZ LES TROIS PARAMETRES DE L'EQUATION : ***\n\n\t\t");
  • printf("\n\n\tA= ");
  • cin>>A;
  • printf("\n\n\tB= ");
  • cin>>B;
  • printf("\n\n\tC= ");
  • cin>>C;
  • DELTA=delta(A,B,C);
  • if (DELTA<0) pasdesolution();
  • if (DELTA>0)
  • {
  • deuxsolutions(A,B,C,DELTA);
  • printf("\n\n\tLES SOLUTIONS SONT: ");
  • printf(fl_char(X1));
  • printf(" et ");
  • printf(fl_char(X2));
  • }
  • if (DELTA==0)
  • {
  • unesolution(A,B,C,DELTA);
  • printf("\n\n\tLA SOLUTION EST: ");
  • printf(fl_char(X));
  • }
  • getch();
  • menu();
  • }
  • //-------------------------------DELTA------------------------------------------
  • float delta(float A,float B,float C)
  • {
  • DELTA=(B*B)-(4*A*C);
  • return DELTA;
  • }
  • //---------------------------RACINE DE DELTA------------------------------------
  • float racine (float DELTA)
  • {
  • long double x = DELTA;
  • RD = sqrt(x);
  • return RD;
  • }
  • //--------------------------------1 SOLUTION------------------------------------
  • float unesolution (float A,float B,float C,float DELTA)
  • {
  • X= (-B)/(2*A);
  • return X;
  • }
  • //--------------------------------2 SOLUTIONS-----------------------------------
  • float deuxsolutions (float A,float B,float C,float DELTA)
  • {
  • RD=racine(DELTA);
  • X1=((-B)+ (RD ))/(2*A);
  • X2=((-B)- (RD ))/(2*A);
  • return X1,X2;
  • }
  • //-------------------------------PAS DE SOLUTION--------------------------------
  • void pasdesolution (void)
  • {
  • clrscr();
  • printf("\n\n\tIL N'Y A PAS DE SOLUTION DEFINIE DANS R POUR CETTE EQUATION");
  • getch();
  • menu();
  • }
  • //----------------------------------ERREUR--------------------------------------
  • void erreur(void)
  • {
  • int choix;
  • printf("\nERREUR DE SAISIE.");
  • getch();
  • clrscr();
  • printf("\n\n\n\n\t\tSOUHAITEZ VOUS REVENIR AU MENU PRINCIPAL ?\n\n\n\n\n");
  • printf("\t TAPEZ :\n\n\n");
  • printf("\t\t1\t POUR\t REVENIR AU MENU PRINCIPAL\n\n");
  • printf("\t\t2\t POUR\t QUITTER LE LOGICIEL\n\n\n");
  • printf("\t CHOIX : ");
  • scanf("%d",&choix);
  • switch(choix)
  • {
  • case 1 : clrscr();
  • menu();
  • break;
  • case 2 : quitter();
  • break;
  • default : erreur();
  • }
  • }
  • //------------------------------QUITTER-----------------------------------------
  • void quitter(void)
  • {
  • clrscr();
  • printf("\n\n\n\t\t\t\t***BYE BYE***\n\n\n\t\t\t");
  • printf("\n\n\n\t\t\t\t\t\t\tPROGRAMME BY SIRIUS\n\n");
  • printf("\t\t\t\t\t\t\tCopyright 2003\n\n\n");
  • /*int stop=0;
  • exit(stop - '0');*/
  • }
  • //------------------------------clrscr()----------------------------------------
  • void clrscr(void)
  • {
  • const char* commande = "cls";
  • system(commande);
  • }
  • //------------------------------clrscr()----------------------------------------
  • char* fl_char (float fl)
  • {
  • int i = 0;
  • while (i< sizeof(fl))
  • {
  • //flchar[i] = fl[i];
  • i++;
  • }
  • return flchar;
  • }
  • //---------------------------------FIN------------------------------------------
  • //By SIRIUS
  • //2003
//------------------------------BIBLIOTHEQUES-----------------------------------



#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream.h>
#include <fstream.h>
#include <ios.h>
#include <PROCESS.H>



//--------------------------------PROTOTYPES------------------------------------

void menu(void);
void quitter(void);
void erreur(void);
void equation(void);
float delta(float A,float B,float C);
float unesolution (float A,float B,float C,float DELTA);
float deuxsolutions (float A,float B,float C,float DELTA);
void pasdesolution (void);
float racine (float DELTA);
void operation(void);
void clrscr(void);
char* fl_char (float);

//--------------------------------VARIABLES-------------------------------------

float A,B,C,DELTA,X1,X2,X,RD;
float fl[30];
char op[100];
char flchar[30];

//--------------------------------PROGRAMME-------------------------------------


void main(void)
{

        menu();
        getche();
        printf("\n\n\n\t\t\t***ERREUR FATALE DU PROGRAMME***\n");
        getch();
        clrscr();
        printf("\n\n\n\t\t\t\t***TANT PIS...***\n");
        getch();
        clrscr();
        quitter();
                       
}
//-------------------------------FONCTIONS--------------------------------------
//---------------------------------MENU-----------------------------------------
void menu(void)
{
clrscr();
printf("\n\t***RESOLUTION D'EQUATIONS DU 2EME DEGRES ET AUTRES CALCULES***\n\n\n\t\t\t");
        int choix=0;

     printf("\n\n\t\t\t     ****************\n");
     printf("\t\t\t     *MENU PRINCIPALE*\n");
     printf("\t\t\t     ****************\n\n\n\n");
     printf("\t   TAPEZ :\n\n\n\n");
     printf("\t\t1\t   POUR\t    RESOUDRE UNE EQUATION DU 2eme DEGRE\n\n");
     printf("\t\t2\t   POUR\t    QUITTER\n\n\n");
     printf("\t   CHOIX : ");
     scanf("%d",&choix);

     switch(choix)
     {
        case 1 :  equation();
        break;

        
        case 2 : quitter();
        break;

        default : erreur();
     }




}

//-------------------------------EQUATION---------------------------------------
void equation(void)
{
clrscr();
printf("\n\n\t\t***ENTREZ LES TROIS PARAMETRES DE L'EQUATION : ***\n\n\t\t");
printf("\n\n\tA= ");
cin>>A;
printf("\n\n\tB= ");
cin>>B;
printf("\n\n\tC= ");
cin>>C;

DELTA=delta(A,B,C);



if (DELTA<0) pasdesolution();

if (DELTA>0) 
			{

	
			deuxsolutions(A,B,C,DELTA);

			
			

			printf("\n\n\tLES SOLUTIONS SONT: ");
			printf(fl_char(X1));
			printf(" et ");
			printf(fl_char(X2));

			}

if (DELTA==0) 
			{

			unesolution(A,B,C,DELTA);
	
		   

			printf("\n\n\tLA SOLUTION EST: ");
			printf(fl_char(X));

			}

getch();
menu();
}

//-------------------------------DELTA------------------------------------------
float delta(float A,float B,float C)
{
DELTA=(B*B)-(4*A*C);

return DELTA;
}
//---------------------------RACINE DE DELTA------------------------------------

float racine (float DELTA)
{
    
    long double x = DELTA;


    RD = sqrt(x);


return RD;
}

//--------------------------------1 SOLUTION------------------------------------
float unesolution (float A,float B,float C,float DELTA)
{
        X= (-B)/(2*A);


		
	

return X;

}

//--------------------------------2 SOLUTIONS-----------------------------------
float deuxsolutions (float A,float B,float C,float DELTA)
{

RD=racine(DELTA);


        X1=((-B)+ (RD ))/(2*A);
        X2=((-B)- (RD ))/(2*A);

		

return X1,X2;

}

//-------------------------------PAS DE SOLUTION--------------------------------
void pasdesolution (void)
{
        clrscr();
        printf("\n\n\tIL N'Y A PAS DE SOLUTION DEFINIE DANS R POUR CETTE EQUATION");
        getch();
        menu();

}





//----------------------------------ERREUR--------------------------------------

void erreur(void)
{
    int choix;

    printf("\nERREUR DE SAISIE.");

     getch();
     clrscr();

     printf("\n\n\n\n\t\tSOUHAITEZ VOUS REVENIR AU MENU PRINCIPAL ?\n\n\n\n\n");
     printf("\t   TAPEZ :\n\n\n");
     printf("\t\t1\t   POUR\t    REVENIR AU MENU PRINCIPAL\n\n");
     printf("\t\t2\t   POUR\t    QUITTER LE LOGICIEL\n\n\n");
     printf("\t   CHOIX : ");
     scanf("%d",&choix);

     switch(choix)
     {
        case 1 : clrscr();
                    menu();
        break;

        case 2 : quitter();
        break;

        default : erreur();
     }
}



//------------------------------QUITTER-----------------------------------------
void quitter(void)
{
	

  clrscr();
  printf("\n\n\n\t\t\t\t***BYE BYE***\n\n\n\t\t\t");
  printf("\n\n\n\t\t\t\t\t\t\tPROGRAMME BY SIRIUS\n\n");
  printf("\t\t\t\t\t\t\tCopyright 2003\n\n\n");
  
  /*int stop=0;
  exit(stop - '0');*/
}

//------------------------------clrscr()----------------------------------------

void clrscr(void)
{

const char* commande = "cls";

system(commande);

}

//------------------------------clrscr()----------------------------------------

char* fl_char (float fl)
{

	int i = 0;
	


	while (i< sizeof(fl))
	{

		//flchar[i] = fl[i];


		
			i++;

	}


return flchar;

}

//---------------------------------FIN------------------------------------------
//By SIRIUS
//2003

 Conclusion

ET VOILA

J'ai aussi corrigé les erreurs qui m'ont été signalées. Merci pour les corrections.


 Sources de la même categorie

Source avec Zip UN EXAMPLE D'APPLICATION EN CUDA DE L'ALGORITHME DE SCAN POU... par oguzaras
Source avec Zip Source avec une capture CHIFFREMENT DE VIGENERE par lajouad
Source avec Zip Source avec une capture ANALYSE SYNTAXIQUE par lajouad
Source avec Zip Source avec une capture STRUCTURE D'UNE MATRICE PAR LES LISTE LINÉAIRE (NON CONTUGUS... par benzarabel
Source avec Zip Source avec une capture DESSINER UNE ARBRE BINAIRE( MODE CONSOLE): par benzarabel

Commentaires et avis

Commentaire de JCDjcd le 08/10/2003 19:41:05

pow(x,0.5)     &lt;=&gt;     sqrt(x)

ATTENTION : X1 = (...)/2*A  NON !!!!!!!!!!!!
c'est X1 = (...)/(2*A) !!!     de meme pour X2 ... les priorites sont importantes

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
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,312 sec (3)

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