First, jump statement break & Continue
Break: Jumps out of the loop, terminates the loop, regardless of how many times there are, skip all.
string a="", for (int i=1; i<=; i++ { if(i==5) { break; }
A + = i + ",";
} Console.WriteLine (a);
Output is 1,2,3,4,5
Continue: Stop this cycle and start the next cycle directly.
string a="", for (int i=1; i<=; i++ { if(i==5) { continue; } A + = i + ",";} Console.WriteLine (a);
Output is 1,2,3,4,6,7,8
Second, iterative method
Iterative algorithm is a basic method to solve the problem by computer. It uses the computer speed, suitable for repetitive operation characteristics, so that the computer to a set of instructions (or a certain number of steps) repeated execution, each time the set of instructions (or these steps), the variable from the original value of the introduction of its new value.
Iterations in the program:
int0; for (int1; i<=; i++) { a++; }
Iii. the method of poor lifting
The basic idea of the exhaustive method is to determine the approximate scope of the answer based on some of the conditions of the topic, and to validate all possible cases within this range until all the circumstances have been verified. If a situation verifies that all the conditions of the subject are met, then it is a solution to the problem and if all the conditions are not met, then there is no solution. The exhaustive method is also known as the enumeration method.
Representative title: Hundred Chicken Hundred money: There are 100 text money, chicken 0.5 article, Rooster 1 Wen Qian, hen 2 Wen Qian. Ask 100 money to buy chicken, each chicken at least one, all chickens a total of 100, ask how many kinds of possible and list each possibility.
int cont = 0;
for (int1; i<=; i++)
{
for (int GJ = 1;gj<=100;gj++)
{
for (int mj = 1;mj< = mj++)
{
if ((xj*0.5) + (gj*1) + (mj*2) = = && XJ+GJ+MJ = = 100)
{
Console.WriteLine ("Chicken" +xj+ "only, a total of" +xj*0.5 "yuan;" Rooster "+gj+" only, a total of "+gj+" yuan; Hen "+mj+" Total "+mj*2+" only, "Yuan";
count++;
}
}
}
}
Console.WriteLine ("A total of" +count+ "possibilities.) ");
The iterative method of C # Jump-statement method for poor lifting