Calcul Equation du Second Degré
2 posters
Trang 1 trong tổng số 1 trang
Calcul Equation du Second Degré
Calcul Equation du Second Degré
http://www.siteduzero.com/forum-83-7304-p1-programme-calcul-equation-du-second-degre.html
http://www.siteduzero.com/forum-83-7304-p1-programme-calcul-equation-du-second-degre.html
- Code:
#include <stdio.h>
#include <stdlib.h>
#include <Math.h>
//Programme Créer par *CyRiL*
//E-Mail : xcyril-57x@hotmail.fr
//date de création : 20/12/2005
int main(int argc, char *argv[])
{
printf ("=========================\n");
printf ("| Calculer une equation |\n");
printf ("| du Second Degre |\n");
printf ("=========================\n");
printf("\n\n\n");
double a=0,b=0,c=0, delta=0;
double rst1=0, rst2=0, rst3=0 ;
printf("Entrer une valeur pour a : ");
scanf("%lf", &a);
printf("Entrer une valeur pour b : ");
scanf("%lf", &b);
printf("Entrer une valeur pour c : ");
scanf("%lf", &c);
if (a==0 && b==0 && c==0)
printf("Tout reel est solution\n");
else {
if(a==0 && b==0 && c!=0)
printf("Il n'y a pas de solution\n");
else if (a==0) {
rst1 = -c/b;
printf("La solution est %lf\n", rst1);
}
else {
delta = b*b - 4*a*c;
if (delta < 0)
printf("Il n'y a pas de solution dans les reels\n");
else {
rst2 = (-b + sqrt(delta))/ (2*a);
rst3 = (-b - sqrt(delta))/ (2*a);
printf("Il y deux solutions egales a %lf et %lf\n", rst2, rst3);
}
}
}
system("PAUSE");
return 0;
}
lx150- Kỵ binh tinh nhuệ
- Tổng số bài gửi : 1095
Points : 2343
Reputation : 0
Join date : 07/07/2010
Đến từ : Ha Noi
Re: Calcul Equation du Second Degré
Giai phuong trinh bac 2 - tieng Phap
http://www.cppfrance.com/codes/RESOLUTION-COMPLETE-EQUATION-SECOND-DEGRE_9982.aspx
http://www.cppfrance.com/codes/RESOLUTION-COMPLETE-EQUATION-SECOND-DEGRE_9982.aspx
- Code:
* /*****************************************************
* Resolution d'une equation de second degree
* a x^2 + b x + c = 0
* Realise par : B. Rochdi et B.S. Mohamed
* Ecole Polytechnique de Tunisie
* ******************************************************/
* #include <stdio.h>
* #include <math.h>
* #include <string.h>
* #include <stdlib.h>
*
* float a,b,c;
*
* /*******************************************************
* ********************************************************/
* float read(x)
* float * x;
* {
* char ch[20];
* scanf("%s",&ch);
* *x = atof(ch);
* }
*
* /*******************************************************
* ********************************************************/
* float Discriminant()
* {
* do
* {
* printf("\n Donner la valeur de a (non nulle): ");
* read(&a);
* }
* while (a==0);
* printf(" Donner la valeur de b : ");
* read(&b);
* printf(" Donner la valeur de c : ");
* read(&c);
*
* return(b*b-4*a*c);
* }
*
* /*******************************************************
* ********************************************************/
* void presentation()
* {
* printf("\n-------------------------------------------------------------\n");
* printf(" Programme de resolution d'une equation de second degree \n");
* printf(" 2 \n");
* printf(" a X + b X + c = 0\n");
* printf("-------------------------------------------------------------\n\n");
* }
*
* /*******************************************************
* ********************************************************/
* int resolution()
* {
* float delta,x1,x2;
* delta=Discriminant();
* printf("\n Delta = %f\n",delta);
* if (delta<0)
* {
* printf(" Delta est negatif, pas de solutions reelles ...\n");
* printf(" Les solutions complexes sont:\n");
* x1=(-b/(2*a));
* x2=(sqrt(-delta)/(2*a));
* printf(" X1 = %f +i (%f)\n",x1,x2);
* printf(" X1 = %f -i (%f)\n\n",x1,x2);
* }
* else
* if (delta==0)
* {
* printf(" Il existe une solution double :\n");
* x1=(-b)/(2*a);
* printf(" X1 = X2 = %f \n\n",x1);
* }
* else
* {
* printf(" Les solutions de l'equation sont :\n");
* x1=(-b-sqrt(delta))/(2*a);
* x2=(-b+sqrt(delta))/(2*a);
* printf(" X1 = %f\n",x1);
* printf(" X2 = %f\n\n",x2);
* }
* }
*
*
* /*******************************************************
* ********************************************************/
* int repeat()
* {
* char rep;
* printf(" Voulez-vous resoudre une autre equation ? (o/n) ");
* scanf("%s",&rep);
*
* return(strcmp(&rep,"n"));
* }
*
*
* /*******************************************************
* ********************************************************/
* int main()
* {
* presentation();
* do
* resolution();
* while (repeat());
* printf("\n\n");
* return(0);
* }
Re: Calcul Equation du Second Degré
Dien dan tieng Viet
http://www.vn-zoom.com/f174/code-dung-c-giai-phuong-trinh-bac-2-a-569915.html
http://ddth.com/showthread.php?t=141746
http://www.vn-zoom.com/f174/code-dung-c-giai-phuong-trinh-bac-2-a-569915.html
http://ddth.com/showthread.php?t=141746
-Nhập vào hệ số a , b , c
-Xét a:
+ a=0 thì x = -c/b;
+ a != 0 (khác 0) thì :
-Xét delta = b*-4*a*c;
+ Nếu delta <0 thì vô nghiệm thuc, co nghiem ao x1= (-b+i*sqrt(-delta))/2*a ;x2 = (-b-i*sqrt(-delta))/2*a ;
+ Nếu delta =0 thì nghiệm x = -b/2*a;
+ Nếu delta >0 thì có 2 nghiệm x1= (-b+sqrt(delta))/2*a ;x2 = (-b-sqrt(delta))/2*a;
Similar topics
» Các cách Tính định thức - Calcul det(A)
» LaTex Style Files + Equation
» Phương trình vi phân tuyến tính cấp 2 (linear second-order ordinary differential equation)
» LaTex Style Files + Equation
» Phương trình vi phân tuyến tính cấp 2 (linear second-order ordinary differential equation)
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|