AwieNN
Picopat
- Katılım
- 10 Ocak 2022
- Mesajlar
- 5
Daha fazla
- Cinsiyet
- Erkek
#include <stdio.h>
int main(void)
{
double x1;
double x2;
double a;
double b;
double c;
double d;
printf("Please enter an integer value a:");
a = getchar();
printf("Please enter an integer value b:");
b = getchar();
printf("Please enter an integer value c:");
c = getchar();
if(a==0)
{
if(b==0)
{
if(c==0){
printf("every number is solution");
}
else{//c != 0
printf("no solution");
}
}
else//b != 0
{
x1 = -c/b;
printf("x1 is ");
printf(x1);
}
}else{//a != 0
d = ((b*b)-4*a*c)/4*a*a;
if(d<0){
x1 = -b/(2*a) +(i)*sqrt(d);
printf(x1 + "\n');
x2 = -b/(2*a) -i*sqrt(d);
printf(x2) ;
}
else if(d==0){
x1 = -b/2*a;
printf("x1 =" + x1);
}
else{//d>0
x1 = (-b/(2*a))+sqrt(d);
x2 = (-b/(2*a))-sqrt(d);
printf("x1 = " x1 '\n');
printf("x2 = "x2");
}
}
}
return 0;
}
int main(void)
{
double x1;
double x2;
double a;
double b;
double c;
double d;
printf("Please enter an integer value a:");
a = getchar();
printf("Please enter an integer value b:");
b = getchar();
printf("Please enter an integer value c:");
c = getchar();
if(a==0)
{
if(b==0)
{
if(c==0){
printf("every number is solution");
}
else{//c != 0
printf("no solution");
}
}
else//b != 0
{
x1 = -c/b;
printf("x1 is ");
printf(x1);
}
}else{//a != 0
d = ((b*b)-4*a*c)/4*a*a;
if(d<0){
x1 = -b/(2*a) +(i)*sqrt(d);
printf(x1 + "\n');
x2 = -b/(2*a) -i*sqrt(d);
printf(x2) ;
}
else if(d==0){
x1 = -b/2*a;
printf("x1 =" + x1);
}
else{//d>0
x1 = (-b/(2*a))+sqrt(d);
x2 = (-b/(2*a))-sqrt(d);
printf("x1 = " x1 '\n');
printf("x2 = "x2");
}
}
}
return 0;
}