Download:Master Java project interview martial arts mind, interview curve overtaking

It is difficult to cover up your lack of technical or development experience. Most of the time, the interviewer does not care about what you have done, but more about your thinking, Angle and way of answering questions. Then how to answer the question, this course will give you the answer!

Suits the crowd

College students facing employment problems

Java engineers facing job hunting problems

Technical reserve requirements

Master Java basics

At least one simulation project development experience analysis: because when b^ 2-4AC >=0, the equation has two real roots, otherwise (b^2-4ac<0) has two conjugate complex roots. The program segment is as follows:

d=bb-4a*c;

if(d>=0)

{x1=(-b+sqrt(d))/2a;

x1=(-b-sqrt(d))/2a;

Printf (” x1 = % 8.4 f, x2 = % 8.4 f \ n “, x1, x2);

}

else

{r=-b/(2*a);

i =sqrt(-d)/(2*a);

Printf (” x1 = % 8.4 f + % 8.4 fi \ n “r, I);

Printf (” x2 = % % 8.4 f – 8.4 fi \ n “r, I);

}

(3) the if… Else if statements have the format:

If (condition 1) {branch 1};

Else if (condition 2) {branch 2}

Else if (condition 3) {branch 3}

Else if (condition n) {branch n}

Else {branch n+1}

The idea is to test the criteria from top to bottom, and when one of the criteria is true, execute its corresponding branch, and then skip out of the entire if else statement to continue executing the other code. If none of the criteria is true, block N is executed and the subsequent code continues.

That is, once a valid test is met, no other branches are executed, so only one branch can be executed.

Although nested branch statements can deal with the problem of multiple entrances and exits, but beyond the three-fold nesting, statement structure becomes very complex, reading and understanding of the program is very inconvenient, the initiative nested within the three-fold, beyond the three-fold can use the following statement.

For example, use multiple if else statements to determine the type of input characters:

#include <stdio.h>

int main(){

char c;

printf(“Input a character:”);

c=getchar();

if(c<32)

printf(“This is a control character\n”);

else if(c>=’0’&&c<=’9′)

printf(“This is a digit\n”);

else if(c>=’A’&&c<=’Z’)

printf(“This is a capital letter\n”);

else if(c>=’a’&&c<=’z’)

printf(“This is a small letter\n”);

else

printf(“This is an other character\n”);

return 0;

}

Operation results:

Input a character: e ↙

This is a small letter

When using the if statement, note the following:

In an if statement, the criterion must be enclosed in parentheses.

The block is surrounded by {}, but note that you do not need a semicolon after the}; (Plus, of course).

When the execution statement of an IF statement is also an IF statement, an IF statement is nested.

If (conditional expression)

If statements.

or

If (conditional expression)

If statements.

else

If statements.

Demo: modify the following procedures so that procedures: input a and B values, determine whether the maximum value is greater than 100, if it is the output maximum value.

int main(void)

{

int a = 0;

int b = 0;

Printf (” Please enter the values of a and b :”);

scanf(“%d%d”,&a,&b);

if(a < b)

if(b > 100)

printf(“max:%d\n”,b);

else

if(a > 100)

printf(“max:%d\n”,a);

return 0;

}

Note: the C language rule, else is always paired with the nearest paired if.

Therefore, the correction should be:

int main(void)

{

int a = 0;

int b = 0;

Printf (” Please enter the values of a and b :”);

scanf(“%d%d”,&a,&b);

if(a < b)

{

if(b > 100)

printf(“max:%d\n”,b);

}

else

{

if(a > 100)

printf(“max:%d\n”,a);

}

return 0;

}

Demo: Enter the values of A, B, and C, identify and output the maximum value

int main(void)

{

int a = 0;

int b = 0;

int c = 0;

int max = 0;

Printf (” Please enter the values of a, b, c :”);

scanf(“%d%d%d”, &a, &b,&c); //

if (a > b)

{

if (a > c)

max = a;

else

max = c;

}

else//b > a

{

if (b > c)

max = b;

else

max = c;

}

printf(“max:%d\n”, max);

return 0;

}

There is no limit to the number of branches that an if else can handle, but it is not easy to handle if else when there are too many branches, and it is easy to make if else matching errors. In this case, switch statements are commonly used instead in practice development.

This statement is also a multi-branch selection statement, and which piece is executed depends on the switch setting, that is, the path where the value of the expression matches the constant expression.

Switch is another alternative to the simple, multi-branched if else statement. The basic form is as follows:

Switch (expression){

Case Integer value 1: statement 1;

Case Integer value 2: statement 2;

.

Case Integer n: statement n;

Default: statements n + 1;

}

Its execution process is:

  1. First compute the value of the “expression”, assumed to be M.

  2. Starting with the first case, compare “integer value 1” and “m”. If they are equal, all statements following the colon are executed, from “statement 1” to “statement n+1”, regardless of whether the following case matches.

  3. If “integer value 1” is not equal to m, skip the “statement 1” after the colon and continue to compare the second case, the third case… Once found to be equal to an integer value, all subsequent statements are executed. Given that m is equal to “integer value 5”, execution continues from “statement 5” to “statement n+1”.

  4. If no equal value is found until the last “integer value n”, then the “statement n+1” after default is executed.

The requirement emphasizes that when a match with an integer value is successful, statements for that branch and all subsequent branches are executed. Such as:

#include <stdio.h>

int main(){

int a;

printf(“Input integer number:”);

scanf(“%d”,&a);

switch(a){

case 1: printf(“Monday\n”);

case 2: printf(“Tuesday\n”);

case 3: printf(“Wednesday\n”);

case 4: printf(“Thursday\n”);

case 5: printf(“Friday\n”);

case 6: printf(“Saturday\n”);

case 7: printf(“Sunday\n”);