-
First of all, the courseinfo method of the school class above is used to display information.
s1, s2, and s3 are already written arrays.
string s1=;
string s2=;
string s3=;
if(coursecode==1) is to judge the input, if it's 1, then iterate through s1 other and so on Will it be clear??
-
To learn the concept of arrays in the C language, print arrays through the for loop output.
-
The function is that when you call the courseinfo function, you type out the contents of the array of parameters string course.
-
The number of for loops depends on the setting mode of the expression, and the initial assignment of variables, the setting of conditional expressions, and the setting of the loop body at the end all affect the number of executions.
1. For example: for(i=1,i<5,i++) The variable i in this is assigned a value of 1, then starting from 1, i<5, when i is a conditional expression, when i is a conditional expression, it does not meet the conditional expression condition, and it will exit the loop. In this case, it is performed a total of 4 times.
2. for loop format:
for(single expression; conditional expressions; 3. When the end of the loop is executed, the condition will be judged again, if the condition is still true, then continue to repeat the above cycle, and when the condition is not true, it will jump out of the current for loop.
-
Problem solving ideas: first enter 10 integers on the keyboard, assume that the first part of the array is the maximum number max, and set the maximum subscript to 0, and then the for loop in turn to determine whether it is greater than the maximum number, if it is greater than the maximum value, replace the maximum value, and update the maximum value subscript, and finally output the largest number and array subscript.
#include
int main()
int i,a[10],max,maxi;
Enter 10 integers.
for(i=0;i. "Wheel Concession 10; i++)
scanf("%d",&a[i]);
Suppose the first part of the array is the maximum number max, and set the maximum subscript to 0max=a[0];
maxi=0;
The for loop determines whether it is greater than the maximum number, and if it is greater than the maximum value, it replaces the maximum value and updates the maximum subscript.
for(i=1;i. Zhou Zheng 10; i++)
if(a[i]>max){
max=a[i];
maxi=i;
Output maximum number and array subscripts.
printf("The maximum number is: %d, and the array subscript is: %d",max,maxi);
return 0;
The result of the program is as follows:
-
Convenient loop array, is to use the first language, the use of loops, arrays, self-addition and self-subtraction, variables and other programming knowledge, all the elements in the applied array space from scratch to assign operations, so that the entire array has a definite value, so as to achieve the purpose of changing the omen to traverse the array.
Looping through an array is an essential step in manipulating the array, otherwise, the entire array is an unknown value, which will seriously affect the operation of the program. Huaibi.
-
1、for...of traversing the array
for...The of loop can be used in place of the foreach method for array instances. for...in a loop to read the key name, for....of of loops to read key values.
2、for...of traverses the map and set structures
3、for...of traversal array of keys() values() entries() objects returned by the map set
4、for...of traversal string
5、for...of traversing the nodelist object
6、for...of traversal arguments
7、for...of traversing non-iterator-like array objects
8、for...of Traversal object
For normal objects, for....The of structure cannot be used directly, and an error will be reported. Use for....in can iterate over the key name of the object.
In short, for....The in loop is primarily designed for traversing objects, not for traversing arrays.
Another way is to use the generator function to rewrap the object a bit.
9、for...of can be used in conjunction with break continue return
Reference Links: Ruan Yifeng ES6 tutorial.
The purpose of smoked meat is to hide for a long time without rotting, the cured meat is fragrant, cooked and sliced, the lean meat is brown and red, the fat is oily but not greasy, and it is suitable for the meal. >>>More
Hangzhou Boiler Plant Manual:
The recirculation system of the boiler is set up to avoid the economizer temperature being too high. To put it simply, it is to protect the economizer, usually when the boiler is not in water, the economizer recirculation pipe must be opened! >>>More
The data is stored in binary form in the computer, the decimal integer can be accurately converted to binary form, and there will be an error when the decimal number of the non-integer number is converted to a single-precision number or a double-precision number, and the non-integer number is used as a cyclic variable, and the step is also a non-integer number, so the number of cycles may not be as desirable. Therefore, you should avoid using non-integer numbers to control the loop. >>>More
In the highway pavement that has been built in China, more than 90 are semi-rigid base asphalt pavement. >>>More
Using a mildly acidic cleanser can keep the pH balance.