-
Cout directly in the function or use a reference such as void function name (double &x1, double &x2) in the parameter table of the function
-
Here's how:
1. The if statement in C C++ programming is the control statement used for conditional judgment, and when the judgment condition is successful, the corresponding statement will be executed, otherwise it will be skipped. The specific form is as follows:
if(expression) statement;
else statement; ] (Optional).
or if statements;
else if(expression) statement;
else if(expression) statement;
else statement;
2. The above description executes the statement when the expression is true, and else is optional, and this statement will be executed when the expression is not true, and can not be used. In addition, if statements support multi-layer nesting, which can be used to determine multiple conditions.
3. The above example is to enter a value, and then output a prompt according to its range. When the if judgment statement is only used for assignment, can it be used? (question mark arithmetic) in the following form:
Variable = (conditional)?Value 1: Value 2
When the condition is true, the value 1 is given to the variable, otherwise the value 2 is given(Question Mark Operator) can also be nested.
4. It means entering a score, then judging which grade range is based on the size of the score, and finally assigning the grade to the C variable.
-
#include
#include
using namespace std;
int main()
int a,b,c;
double d,e,f;
cout<<"Please enter a, b, c";
cin>>a;
cin>>b;
cin>>c;
fixed);
showpoint);
d=(-b)/2*a;Real part e=(sqrt(abs(b*b-4*a*c))) 2*a; Imaginary part.
f=b*b-4*a*c;
if(f>0)
cout<<"There are two unequal solid roots"<
-
What's your h[i]?
You say I don't understand that, but syntactically it's not a long float, it's a double. And this symbol is not, but should use the pow (base, exponent) function, the base, the exponent is double or float
-
This is a classic question.
I've seen this question in many places.
**As follows: include
#include
voidf(float
m,float
n,float
l)if(deta==0)
printf("The equation has a solution. x=%g",x1);
if(deta>0)
printf("The equation has two solutions. x1=%g,x2=%g",x1,x2);
main()
Here's a picture of how the program works:
-
#include
#include
using namespace std;
int main()
elseelse if(delta<0)
elsereturn 0;
If you have something wrong in it, you can see for yourself, and that delta a b c has not been given a value, how can you calculate it? Look at the answer I gave you! Hehe, I learned math well in high school!
The situation analysis is in place! Not bad! The classification is just right!
-
Is this a program-based course?
-
The above logic is not clear, I'll write you one, you have the right to refer to Suppose the equation is x 2 = 2; It can also be described according to the function parameters, which is simplified here.
[a,b] is the value range, n iterations.
float get2value( int a, int b, int n)
..return x;}
-
The algorithm is so clear, why bother with the source program.
-
Warning: bai is normal, there is a problem with the output.
Changed the du function and improved it.
#include
#include
#include
void main()}
-
#include
#include
int main()
Enter yes to continue, enter no to exit*
printf("Please enter values for a, b, c");
printf("a=");scanf("%f",&a);
printf("b=");scanf("%f",&b);
printf("c=");scanf("%f",&c);
p=b*b-4*a*c;
if(p<0) *Determine whether there is a real root, if not, exit* q=-b 2*a;
if(p==0) printf("This equation has two equal real roots x1=x2=%f",q-sqrt(p));
-
#include
#include
void main()
q=(float)-b/2*a;
p=(float)sqrt(b*b-4*a*c);
x1=q-p;x2=q+p;
if(res<0)
printf("--- equation has two equal roots of real numbers, x1=x2=%2f", x1);
elseprintf("x1=%.1f,x2=%.1f, x1, x2");}
The original meaning of the question is to implement the function of one queue with two stacks. >>>More
int max(float fx,float fy)float fz;
fz=fx>fy?fx:fy; >>>More
1. In Excel 2010, create a new Excel document, and then open it as shown in the following figure. >>>More
Disability compensation for 2 grade 10 disability = per capita disposable income of urban (rural residents) in the previous year at the location of the court where the lawsuit is filed Disability coefficient (12%) The number of years of compensation varies slightly from region to region, and the specific reference is to the local standard. >>>More
In the process of getting along with two people, they must think more about each other, think about it from each other's point of view, tolerate and care for each other, and they will naturally understand each other after a long time.