-
if (b*b-4*a*c==0)
printf("x1=x2=%.6f",-b/(2*a));
elseif(b*b-4*a*c>0)
printf("x1=%.6lf",(-b-sqrt(b*b-4*a*c))/(2*a));
printf("x2=%.6lf",(-b+sqrt(b*b-4*a*c))/(2*a));
else printf("x1=%.6lfi",(-b-sqrt(4*a*c-b*b))/(2*a));
printf("x1=%.6lfi",(-b+sqrt(4*a*c-b*b))/(2*a));
Each else should correspond to the nearest if, and what you have is incorrect, such as lines, which are mostly enclosed in curly braces.
There are also the variables of the double type you define [double x,x1,x2; If you are not involved in the operation, you can get rid of the defined statement.
-
In the red box in the figure, there is a hungry finch misstate calendar in the red box, which in the C language is already an XOR operation, requiring that both sides must be integers, so you will get an error when you use the double type.
The open square root can be used with the double sqrt (double num) library function.
-
If there is an input error, do not separate it with a comma, but separate it with a space, because the previous format string is %f%f%f.
See the introduction of SCANNF below
1.The first parameter of the function is the format string, which specifies the format of the input, parses the information of the corresponding position of the input according to the format specifier, and stores it in the corresponding pointer in the list of variable parameters. Each pointer must be non-null and correspond to the formatters in the string one by one.
2.If %d is written consecutively in scanf, such as "%d%d%d%d", the data should not be separated by commas, but only separated by whitespace characters (spaces or tab keys or enter) - "2 (space) 3 (tab) 4" or "2 (tab) 3 (enter) 4", etc. If it is "%d,%d,%d", you need to add "," when entering data, such as "2,3,4".
-
scanf("%f%f%f", &a, &b, &c);
1 5 6 when entered
The middle space is separated, don't use any commas, enter and enter, this enter is free, you don't need to pay for it. Don't stuff printf-only stuff in the scanf format string, that will be a mess.
-
<> is not in parentheses. Amend the sentence to read:
printf("The solution of this equation is x=%f or.
Successful results:
-
No problem.
1. When you enter 1 1 1:
2. When entering 1 4 4:
3. When entering 1 5 4:
4. When entering 1 6 4:
It's pretty much the same as what I did with a calculator:
There's no problem, what a mistake you said.
-
Personally, I think it may be wrong to find the root 1 root 2, if the delt square is exactly an integer number, then it should be rounded, you try to change the following 2 to can.
-
Can it be assigned like this?
It should be divided into two lines:
x1 = (-b+sqrt(disc))/(2*a);
x2 = x1;
The void ziq() part doesn't say anything Sark, just turn it around. >>>More
If you define r as int, enter 10000 and that will automatically force the type conversion when multiplied. >>>More
It's not very hard that the tail node next points to null. >>>More
It's called the [batch] program, in fact, don't think that the program you mentioned above to deal with garbage is really powerful, it's amazing, when you have learned DOS, that program can be said to be a very simple thing; >>>More
I feel very simple...
#include >>>More