The structured statements in c ++ determine the use of if branch statements switch loop statements while and do while loop statements for, structured switch
Job 1:
Use the if statement, according to 1 ~ 7. What is the day of the week output? Program.
Method 1: directly use a separate if statement
# Include
Method 2: Use the associated if statement
# Include
Exercise questions: Finish the seasonal output o
Print out a right triangle with a *. High 8*.public class Zhijiaosanjiaoxing {public static void Main (string[] args) {for (int i=0;ifor (int k=0;kSystem.out.print ("*");}System.out.println ();}}}Requires * To print a isosceles triangle.public class Dengyaosanjiaoxing {public static void Main (string[] args) {for (int i=0;ifor (int k=8;k>i;k--) {System.out.print ("");}for (int j=0; jSystem.out.print ("*");}System.out.println ();}java--Program Flow Control--L
= DateTime. Now. Ticks;For (int I = 0, n = p. Child. Alias. Length; I // Console. Write (lenArray [I]);}Long l4 = DateTime. Now. Ticks;Console. WriteLine ("Ending. \ nTime is:" + (l4-l3). ToString ());S = Console. ReadLine ();}Console. Read ();}}
The larger the data volume, the larger the class, the more obvious the difference.
Conclusion:The impact should be on the reason why variables need to access the lower-level variables in each loop. If it's j
The most basic syntax format in Python is probably indentation. Common loops in Python: for loops, if loops. A little game illustrates the use of for,if, break.Guess number game:1. The system generates a random number within 202. The player has 6 chances to guess, each guess will have feedback results, guess big, guess small or guessed right-end3.6 Chances, guess right, player wins4, 6 chances, no guess, system wins.The code is as follows:[email protected] python-scripts]# cat 12.py#!/usr/bin/py
Core: On the issue of this point, it is best to print out this to seeYou can render that array on the page.You'll see something magical, even time and space.Solution:GetList () { Let _this=this Let params={ Currentpage:_this.currentpage, Pagesize:_this.pagesize, } _this.ajax ({ Type: "Post", Data:params, URL: "/author/fans/fanstimelist", Success (RES) { _this.listdata=res.responsebody.data Console.log (_this.listdata, ' data printing ') Console.log
While Condition;doStatmentDoneUntil Condition;doStatmentDonePractice:Write a script: every five seconds to see if JT has landed, did not login to continue to execute, landed the Stop command650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/4D/A5/wKioL1RWFsOAf8tbAAEJjcmWsbw815.jpg "title=" 2.jpg " alt= "Wkiol1rwfsoaf8tbaaejjcmwsbw815.jpg"/>650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4D/A5/wKiom1RWFbfA9ZcGAAEWE3ndbY0780.jpg "title=" QQ picture 20141102192828.jpg "alt=" Wkio
= DateTime.Now.Ticks;
for (int i = 0, n = p.child.alias.length i Console.Write (Lenarray[i]);
}
Long L4 = DateTime.Now.Ticks;
Console.WriteLine ("Ending.\ntime is:" + (L4-L3). ToString ());
s = Console.ReadLine ();
}
Console.read ();
}
}
The larger the amount of data, the larger the class, the more obvious the difference.
Conclusion: The effect should be on the reason that the variable accesses the next-level variable in each loop
Problem: Computes the number in the ffff:0006 unit multiplied by 3, and the result is stored in the DX.
Answer:
One: Analysis of ideas:
1. Whether the result of the operation will exceed the range that DX can store. The book in the ffff:0006 unit is a byte-type data, 8-bit, which ranges between 0 and 2 of eight parties, and the maximum is 2 of 8, or 255. Then the value after multiplying it with 3 is 255X3=765=02FDH. And the maximum value that DX can store is 2 of 16 square, namely 65535=0FFFFH,
First, the contentSecond, the String methodHttp://www.cnblogs.com/fyknight/p/7895894.htmlThird, practice1. Write A For loop and use the index to iterate through each character2. Write a while loop and use the index to iterate through each character3. Replace ' world ' with Python in msg= ' Hello World '4, the character's file name, file size, operation method cutting outmsg= '/etc/a.txt|888|get '5, write a
This article brings you the content is about the PHP in the use of foreach () If you want to jump out of the loop or terminate the loop implementation method, there is a certain reference value, the need for friends can refer to, I hope to help you.
Example one:
In PHP, in a foreach () loop, you want to be in a loop
Yesterday, my colleague asked me a question. There are two loop statements:
For (I = N; I> 0; I --){...}
For (I = 0; I {...}
Why is the former faster than the latter?
My explanation at the time was:
I -- the operation itself will affect CPSR (currentProgramStatus Register), CPSR common signs are N (result is negative), Z (result is 0), C (input), O (overflow ). I> 0, which can be determined directly by the Z mark.
The I ++ operation also a
The data table fields are the ID Name field below the value has 1 32 Li 43 Wang 54 Li four I want to implement the Foreach loop output name value But John Doe output only once
things 2If condition 2:Meet the conditions 2 do things 1Meet the conditions 2 do things 2#下面是一个小应用猜拳游戏:Here is the method used by the Python3 input if else print randomImport RandomPlayer = input (' Please Enter: Scissors (0) stone (1) cloth (2): ')Player = Int (player)#产生随机整数: One of 0, 1, 2Computer = Random.randint (0,2)#用来进行测试Print (' player=%d,computer=%d ', (player,computer))if (player = = 0) and (computer = = 2)) or ((Player ==1) and (computer = = 0)) or ((player = = 2) and (computer = =
Loop ExitFor loop:ForElseThe For loop will execute the ELSE statement if it ends normally.Script 1:#!/usr/bin/env python for I in Xrange (10):Print IElse:Print "Main End"Results:[email protected] 20171227]# python exit.py0123456789Main end[Email protected] 20171227]#Script 2:#!/usr/bin/env pythonImport timeFor I in Xrange (10):Print ITime.sleep (1)ElsePrint "Main End"Result: (Press CTRL + C interrupt)[email
A For loop is nested similar to if else
Case:Print matrixfor (int k = 1; k {for (int i = 1; I {Console.Write ("");}Console.WriteLine ();}
Print triangle with right angle at bottom leftfor (int i = 1; I {for (int j = 1; J {Console.Write ("");}Console.WriteLine ();}
The upper left corner is a rectangular trianglefor (int i = 1; I {for (int j = 5; J >= i; j--){Console.Write ("");}Console.WriteLine ();}
The bottom right corner of the print triangle is
A dead loop was encountered while porting a Windows program to Linux, and finally a statement similar to this was located for (i = 0; i Don't ask me who wrote it, why do you write it so ( tear eyes !) ).According to the common sense of c, i = i++ should be equivalent to i++, it is true on Windows, but Linux is not, this should be caused by compiler differences.---------------------------------------Split-line no.0-------------------------------------
Until cycleThe environment used to perform loops when a proposition is falseWhen a proposition is false, it enters the loop; exit the loop when the proposition is trueOr if the condition is not satisfied, enter the cycle of the sceneIn logical judgment, until and while are just the opposite.Syntax format:Until CONDITION; DoLoop bodyDoneEntry condition: CONDITION is FalseExit Condition: CONDITION is TrueUnti
Scene:
When you import more than one piece of data through Excel (insert multiple data at once into the database), to read, parse Excel, and loop into each piece of data, before inserting a piece of data to determine whether the data already exists, if there is a continue exit the current loop, into the next cycle. For example:
Break : Jump out of the loop
for
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.