Viet

Contenu du snippet

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 / Exemple :

//------------------------------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.

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.

Du même auteur (Siriusgalaxie26)