begin process at 2012 05 27 14:05:39
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Maths & Algorithmes

 > CALCUL DE RACINES (AMELIORÉ)

CALCUL DE RACINES (AMELIORÉ)


 Information sur la source

Note :
Aucune note
Catégorie :Maths & Algorithmes Niveau :Débutant Date de création :14/03/2002 Date de mise à jour :14/03/2002 13:29:36 Vu / téléchargé :3 711 / 67

Auteur : ndj55

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

 Description

Voilà une version améliorée du programme de 'obasileus' qui sert à calculer des racines... Cette version est largement améliorée,plus précise,plus rapide et plus souple...

Source

  • /**************************************\
  • * Root Calculator *
  • * Version 1.00 *
  • * Started The 11th March 2002 *
  • * By Nicolas BENOIT, ndj55@free.fr *
  • * http://www.ndj55.fr.fm *
  • \**************************************/
  • /*
  • Ce programme est basé sur le programme 'Racine' créé par obasileus.
  • */
  • //--------------------------------------------------------------------------------
  • //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  • //--------------------------------------------------------------------------------
  • #include <stdio.h>
  • //--------------------------------------------------------------------------------
  • //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  • //--------------------------------------------------------------------------------
  • int main(void)
  • {
  • unsigned long int nombre = 0;
  • unsigned long int iteration = 0;
  • unsigned long int diviseur = 2;
  • double temp;
  • double root;
  • printf("Carre de la racine recherchee : ");
  • scanf("%i",&nombre);
  • printf("Precision : ");
  • scanf("%i",&iteration);
  • temp = nombre / 2.0;
  • root = temp;
  • while (iteration != 0)
  • {
  • if (((root * root) > nombre) && (root > 0))
  • {
  • root -= (temp / diviseur);
  • }
  • else
  • {
  • root += (temp / diviseur);
  • }
  • if ((root * root) == nombre)
  • {
  • break;
  • }
  • diviseur += 2;
  • --iteration;
  • }
  • printf("\a\n\nRacine Approximative =\t%.10f\nCarre Approximatif =\t%f\n",root,root*root);
  • getchar();
  • while (getchar() == 0)
  • {
  • getchar();
  • }
  • return 0;
  • }
  • //--------------------------------------------------------------------------------
  • //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  • //--------------------------------------------------------------------------------
/**************************************\
* Root Calculator                                           *
* Version 1.00                                               *
* Started The 11th March 2002                        *
* By Nicolas BENOIT, ndj55@free.fr                 *
* http://www.ndj55.fr.fm                                *
\**************************************/

/*
Ce programme est basé sur le programme 'Racine' créé par obasileus.
*/

//--------------------------------------------------------------------------------
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//--------------------------------------------------------------------------------


#include <stdio.h>

//--------------------------------------------------------------------------------
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//--------------------------------------------------------------------------------

int main(void)
{
    unsigned long int	nombre		= 0;
    unsigned long int	iteration	= 0;
    unsigned long int	diviseur	= 2;

    double temp;
    double root;

    printf("Carre de la racine recherchee : ");
    scanf("%i",&nombre);
    printf("Precision : ");
    scanf("%i",&iteration);

    temp = nombre / 2.0;
    root = temp;

    while (iteration != 0)
    {
            if (((root * root) > nombre) && (root > 0))
            {
                    root -= (temp / diviseur);
            }     
            else
            {			
                     root += (temp / diviseur);
            }

            if ((root * root)  == nombre)
            {
                     break;
            }

            diviseur += 2;		
             --iteration;
      }

      printf("\a\n\nRacine Approximative =\t%.10f\nCarre Approximatif   =\t%f\n",root,root*root);

      getchar();

      while (getchar() == 0)
      {
             getchar();
      }

       return 0;
}

//--------------------------------------------------------------------------------
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//-------------------------------------------------------------------------------- 

 Conclusion

Une précision de 32000 permet d'obtenir un résultat exact presque à tous les coups....

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Sources du même auteur

Source avec Zip [GCC] CRÉATION D'UNE SOCKET ET CONNEXION A UN SERVEUR WEB......
Source avec Zip IMPLÉMENTATION DE L'ALGORITHME DE DIGHSTRA (PLUS COURT CHEMI...
Source avec Zip PANDEMONIUM, UN PENDU-LIKE... NOUVELLE VERSION
Source avec Zip PANDEMONIUM, UN PENDU-LIKE...

 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 kjus le 04/09/2002 10:14:49

salut !
pour calculer une approximation de racine carré, il existe un algorithme simple et très rapide : l'algorithme d'héron.
En 8 itérations, on a deja une très bonne précision ! (l'algo utilise les suites)
J'en ai codé une version ici :
http://www.cppfrance.com/article.aspx?Val=874

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

Photothèque

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 : 1,045 sec (3)

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