-
#include
void main()
int a[10],i,sum=0;
printf("Please enter a number of ten:");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(i=0;i<10;i++)
if(a[i]<0)
printf("%d ",a[i]);
sum=sum+a[i];
printf("The sum of all negative numbers is: %d",sum);
-
There are 2 types of programmed loop structures, and
Hello, I have found the following for you: There are 2 types of circular structures for programming, (+ and (+) The three basic structures of structured programming are: sequential structure, selection structure and loop structure.
Sequential structureThe sequential structure indicates that the actions in a program are performed in the order in which they appear. Choosing a structureA structure indicates that a branch has appeared in the processing steps of the program, and it needs to select one of the branches to execute according to a specific condition. There are three types of selection structures: single choice, double choice and multiple choice.
Loop structureA loop structure means that a program performs one or more actions repeatedly until a condition is false (or true) before terminating the loop.
-
A loop consists of two parts: a statement that controls the loop and a loop body.
1. Cycle initialization part - initialize the cycle control variables and variables used in the cycle body;
2. Circulating body part - the main body of the circulating structure;
3. Cycle adjustment part - the modification of cycle control variables, or the inspection of cycle termination conditions;
4. Cyclic control part - the control transfer of program execution.
-
1. Cycle initialization part - initialize the cycle control variables and variables used in the cycle body;
2. Circulating body part - the main body of the circulating structure;
3. Cycle adjustment part - the modification of cycle control variables, or the inspection of cycle termination conditions;
4. Cyclic control part - the control transfer of program execution.
-
In the loop program structure, which of the following nuclei should we do before looping ()aCycle Digging Ring Initialization.
b.Circulating bodies.
c.Circular variable modification.
d.The cycle condition judgment is corrected.
Correct Answer: a
-
When designing a double cycle program, the following description is correct ()aThe initial value of the external circulation of the rock fiber ring should be imitated outside the external circulation; The initial value of the inner circulation should be placed outside the inner circulation and within the outer circulation.
b.The initial value of the outer circulation should be placed in the outer circulation; The initial value of the internal circulation should be placed in the internal circulation jujube.
c.Both the initial value of the inner and outer circulation should be placed outside the outer circulation.
d.The initial value of the inner and outer circulation should be placed outside the inner circulation and inside the outer circulation.
Correct Answer: a
-
The loop structure in the algorithm must be implemented by a while statement. Selection is a basic cyclic pattern of the computer. When the condition is met, it enters the loop, and after entering the loop, when the condition is not met, it jumps out of the loop.
The general expression of the while statement is rent-buried: while. A loop statement consists of two parts: the loop body and the end condition of the loop.
-
Answer: A Idea analysis: There are two kinds of cyclic structures in the algorithm, and there are also two kinds of cyclic statements corresponding to the limb comma, namely the while statement and the for statement, so the cyclic structure in the algorithm can be realized by two kinds of cyclic statements.
From this, it can be seen that only A is incorrect in the 4 options.
-
Loops reflect the way of thinking of computers, for us humans, loops are unnatural, who would make up a loop for themselves to live like a robot. Therefore, the focus of the cycle is not to learn how to write a cycle**, but to experience how to transform our understanding of the problem into a circular means to solve it.
1. Circular structure.
The repetition is controlled, such as continuing to repeat until a certain condition is met or how many repetitions are completed. That is, the need for control over repetitive work is called cyclic control.
The part of the work that repeats is called the loop body, and the preparation work done to implement the loop is called initialization.
2. While statement (current loop).
The general form of a while statement.
while( expression).
Statement; The execution process is as follows: first calculate the value of the expression after while, if its value is "true", then execute the loop body, after the loop body is executed, calculate the value of the expression after while again, if its value is "true", continue to execute the loop body, if the value of the expression is false, exit the loop structure.
The last sentence is wrong, you have already swapped the values of the original b and c in the second if sentence, which means that the value of a must be greater than the value of c, and at this time, the value of a is not necessarily greater than the value of b, so this is not good.
VB design.
Introduction. What is required. >>>More
Not popular, but much easier to learn than other languages.
Add 2 buttons, 2 textboxes, 1 listbox, and you can't go wrong. >>>More
First of all, let's introduce the method of deleting the stubborn update folder in the win2000 system (the method is similar to the winxp win2k3 system). >>>More