Home > database >  notes
notes

Time:10-06

Cycle: repeat similar code, range -- -- -- -- -- - determine three elements: you need to use the circulation loop loop condition (usually and loop variable range), the loop body (repeat similar code), loop variables (loop variables of initial value, the change of the loop variable) 1, while loop loop variable initialization while (loop condition) {loop body loop variable changes} 2, the do... The while loop variable initialization do {loop body circulation variable changes} while (circulation conditions); * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1, for loop syntax: for (expression 1; Expression is 2; Expressions perform 3)} {loop body: first, the expression 1, and then judge whether expression 2, if the execution of the loop body established, the expression of 3, then continue to determine whether expression 2, execute the loop body... If the expression was not 2 end loop expression for loop conditional expression 1 2 is executed only once, usually for the loop variable initialization expression. 3 for the change of the loop variable expression usually 1, 2, 3 can be omitted entirely, but the semicolon cannot omit 2, the comma operator, how it works: separator, can take multiple expression, by a comma, connect into a comma expression for (I=1, sum=0; 1<101; Sum +=I, i++) comma expression of the solution: since to right to calculate each expression, and finally the value of an expression, as the entire value of the comma expression, in the actual programming, rarely used comma expression the value of the operator (operational property, priority, associativity) - expression (the value of the expression) int x=(I=1, sum=0);===& gt; X=0 for (I=0; (c=getchar ())!=' ')

CodePudding user response:

Please note sent to personal blog, thank you
Prev:notes