Systeme de cramer suivant gauss - Programmation
Dans la même thématique :
Ceci répond-il à votre question ? Oui | Non
 

Ajouter une réponse



 Mot :   Pseudo :  
 
Bas de page
Auteur
 Sujet : Systeme de cramer suivant gauss
 
Profil : IDNaute
Plus d'informations

bonsoir je voulais vous faire vérifier le passage en algorithme de gauss je crois que pour la matrice A c'est bon mais j'ai un doute sur le second membre vous auriez pas un exemple...est-ce que c'est bon ce que j'ai fais?  
 
#define N 50
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
 
main()
{
 
 //déclaration des variables
 
 int n,i,j,k;
 float A[N][N],B[N],X[N],C;
 
 printf("\n\t\t    !!!!RESOLUTION D'UN SYSTEME CRAMER-GAUSS!!!!\n" );
 
 //nombre d'inconnu
 
 do
 {
  printf("\n\nQuel est le nombre d'inconnu (0<N<50)? " );
  scanf("%d",&n);
 }
 while((n<=0)||(n>N));
 
 //acquisition de la matrice A
 
 system("cls" );
 printf("\n\t\t    !!!!RESOLUTION D'UN SYSTEME CRAMER-GAUSS!!!!\n" );
 printf("\n\n\tSaisie des coefficients de la matrice A\n" );
 printf("\nL'‚l‚ment diagonal doit ˆtre diff‚rent de 0\n\n" );
 for(i=0;i<n;i++)
 {
  for(j=0;j<n;j++)
  {  
   // do
  //{
    printf("Entrez le coefficient A %d %d: ",i+1,j+1);
    scanf("%f",&A[i][j]);
   //}
   //while(A[i][i]==0);
  }
 }
 printf("\n\nMatrice A:\n\n\t" );
 for(i=0;i<n;i++)
 {
  for(j=0;j<n;j++)
  {
   printf("%5.2f ",A[i][j]);
  }
  printf("\n\t" );
 }
 getche();
 
 //acquisition du second membre  
 
 system("cls" );
 printf("\n\t\t    !!!!RESOLUTION D'UN SYSTEME CRAMER-GAUSS!!!!\n" );
 printf("\n\n\tSaisie des coefficients du second membre B\n\n" );
 printf("\nLe nombre d'‚l‚ments est: %d\n\n",n);
 for(i=0;i<n;i++)
 {
  printf("Entrez le coefficient B %d: ",i+1);
  scanf("%f",&B[i]);
 }
 printf("\n\nSecond membre B:\n\n\t" );
 for(i=0;i<n;i++)
 {
  printf("%5.2f\n\t",B[i]);
 }
 getche();
 
 //affichage de votre système
 
 system("cls" );
 printf("\n\t\t    !!!!RESOLUTION D'UN SYSTEME CRAMER-GAUSS!!!!\n" );
 printf("\n\nMatrice A:\n\n\t" );
 for(i=0;i<n;i++)
 {
  for(j=0;j<n;j++)
  {
   printf("%5.2f ",A[i][j]);
  }
  printf("\n\t" );
 }
 printf("\n\nSecond membre B:\n\n\t" );
 for(i=0;i<n;i++)
 {
  printf("%5.2f\n\t",B[i]);
 }
 printf("\n\nInconnu X:\n\n\t" );
 for(i=0;i<n;i++)
 {
  printf(" X %d\n\t",i+1);
 }
 getche();
 
 //algorithme de Gauss
 
 system("cls" );
 printf("\n\t\t    !!!!RESOLUTION D'UN SYSTEME CRAMER-GAUSS!!!!\n" );
 for(i=0;i<n;i++)
 {
  C=A[i][i];
  for(j=0;j<n;j++)
  {
   A[i][j]=A[i][j]/C;
   B[i]=B[i]/C;
  }
  for(k=i+1;k<n;k++)
  {
   for(j=0;j<n;j++)
   {
    A[k][j]=A[k][j]-A[k][i]*A[i][j];
    B[k]=B[k]-A[k][i]*B[i];
   }
  }
 }
printf("\nVoici votre sytŠme selon l'agorithme de Gauss" );
 printf("\n\nMatrice A:\n\n\t" );
 for(i=0;i<n;i++)
 {
  for(j=0;j<n;j++)
  {
   printf("%5.2f ",A[i][j]);
  }
  printf("\n\t" );
 }
 printf("\n\nSecond membre B:\n\n\t" );
 for(i=0;i<n;i++)
 {
  printf("%5.2f\n\t",B[i]);
 }
 printf("\n\nInconnu X:\n\n\t" );
 for(i=0;i<n;i++)
 {
  printf(" X %d\n\t",i+1);
 }
 getche();
}
 
 
 

Liens

Profil : IDNaute
Plus d'informations

---------------
B800A0 8EC0 B400 B013 CD10 B91000 BA1000 B005
E81000 B407 CD21 B400 B003 CD10 B44C B000 CD21
50 89D0 BB4001 F7E3 89C7 01CF 58 26 8805 C3
Profil : IDNaute
Plus d'informations

merci j'ai déjà vu le lien...mais sur la programmation est-ce que c'est bon?  
merci

Profil : IDNaute
Plus d'informations

A priori oui. Le résultat que tu obtiens est bien celui attendu?


---------------
B800A0 8EC0 B400 B013 CD10 B91000 BA1000 B005
E81000 B407 CD21 B400 B003 CD10 B44C B000 CD21
50 89D0 BB4001 F7E3 89C7 01CF 58 26 8805 C3
Profil : IDNaute
Plus d'informations

j'en sais trop rien justement  :heink:
faudrait que je continue le traitement mais je suis completement largué...


Message édité par sutefuane le 14-04-2008 à 19:17:22
Profil : IDNaute
Plus d'informations

Bonsoir,  
est-ce que quelqu'un pourrait me dire où j'ai faux car je trouve pas...


Aller à :
Ajouter une réponse
  FORUM Infos-du-Net » Programmation » Systeme de cramer suivant gauss
 

Liens