When will Zhaoping Vocational Education Center register
Publish: 2021-05-24 23:12:50
1. As long as there is no cancellation of student status, if you want to know more specific information, I suggest you consult the teacher
2. 1. Definition of C language structure array: array is an ordered set of data with the same type
2. A structure array is a set of variables with the same structure type. If you want to use C language to define the name, gender, age and address of 40 students in a class, you can make a structure array
array elements are used as structural variables to access the members of a structural array. Its form is:
1. Structural array element member name
2. For example: student [0]. Name, student [30]. Age
3. In fact, a structure array is equivalent to a two-dimensional structure. The first dimension is a structure array element, each element is a structure variable, and the second dimension is a structure member
note: the members of a structure array can also be array variables.
2. A structure array is a set of variables with the same structure type. If you want to use C language to define the name, gender, age and address of 40 students in a class, you can make a structure array
array elements are used as structural variables to access the members of a structural array. Its form is:
1. Structural array element member name
2. For example: student [0]. Name, student [30]. Age
3. In fact, a structure array is equivalent to a two-dimensional structure. The first dimension is a structure array element, each element is a structure variable, and the second dimension is a structure member
note: the members of a structure array can also be array variables.
3. int tmp[] =stu1[k];< br />stu1[k] =stu1[k+1];< br />stu1[k+1] =tmp;
one idea of bubble sort is to compare and exchange positions in pairs
your code, if the value of K is greater than K + 1, exchange the positions of K and K + 1, and put the maximum value at the end. In this way, under the sub loop, the value of array 0 is the minimum, and TMP is used to save the value temporarily in the middle< br />int tmp[] =stu1[k]; It is to assign the value of K to TMP
stu1 [k] = stu1 [K + 1]; It is to assign the value of K + 1 to K
stu1 [K + 1] = TMP; It is to assign the original value of K to K + 1
one idea of bubble sort is to compare and exchange positions in pairs
your code, if the value of K is greater than K + 1, exchange the positions of K and K + 1, and put the maximum value at the end. In this way, under the sub loop, the value of array 0 is the minimum, and TMP is used to save the value temporarily in the middle< br />int tmp[] =stu1[k]; It is to assign the value of K to TMP
stu1 [k] = stu1 [K + 1]; It is to assign the value of K + 1 to K
stu1 [K + 1] = TMP; It is to assign the original value of K to K + 1
4. First, s [12] stores 12 numbers, and C [5] contains all zeros
the second for loop is used for output. It can be seen that it outputs four numbers from C [1] to C [4]
the first for run is used to assign values:
when I = 0, s [i] = 1; c[s[i]]=c[1]=0; c[1]++ = 1;
when I = 1, s [i] = 2;; c[s[i]]=c[2]=0; c[2]++ =1;
... / / I assign C [0] to C [3] to 1 from 0 to 3
when I = 4, s [i] = 4; c[s[i]]=c[4]=1; c[4]++ =2;
when I = 5, s [i] = 3;; c[s[i]]=c[3]=1; c[3]++ =2;
.... / / now we should be able to see the rule: for every 1 in s [12], add one to C [1]; Every time there is a 2, then C [2] is added
so there are four 1's, three 2's, three 3's, two 4's in s [12]
so the output from C [1] to C [4] is 4332
the second for loop is used for output. It can be seen that it outputs four numbers from C [1] to C [4]
the first for run is used to assign values:
when I = 0, s [i] = 1; c[s[i]]=c[1]=0; c[1]++ = 1;
when I = 1, s [i] = 2;; c[s[i]]=c[2]=0; c[2]++ =1;
... / / I assign C [0] to C [3] to 1 from 0 to 3
when I = 4, s [i] = 4; c[s[i]]=c[4]=1; c[4]++ =2;
when I = 5, s [i] = 3;; c[s[i]]=c[3]=1; c[3]++ =2;
.... / / now we should be able to see the rule: for every 1 in s [12], add one to C [1]; Every time there is a 2, then C [2] is added
so there are four 1's, three 2's, three 3's, two 4's in s [12]
so the output from C [1] to C [4] is 4332
5. If the constructor is not defined, the data members will be copied one by one by default. The value used is the data member value of the object after =
the problem you mentioned is that you don't understand how constructors work. If you define a constructor, use this function; otherwise, use the default constructor ( data members one by one like constructor). But the constructor you defined has only output statements, and the parameters have no default values. All initialization errors will occur
/ /
I've just experimented, and I think you still don't understand deeply enough. You did an example, compiled and passed, but didn't see the result< As a matter of fact, there are several points to be made clear:
first, a class is different from the struct in C, generally {} initialization object is not needed
MSDN help information:
compiler error c2552
& 39; identifier' : non-aggregates cannot be initialized with initializer list
The specified identifier was incorrectly initialized.
An initializer list is needed to initialize the following types:
An array
A class, structure, or union that does not have constructors, private or protected members, base classes, Or virtual functions
these types are known as "aggregates.
the class you defined has a constructor, which does not meet the above conditions. You can't use {}
2. If there is no assignment statement in the custom constructor, even if it is called, its data members X and y will only be random values (change the definition of stu2 to stu2 (1,2); If you change the constructor to the following:
stu (int a = 0, int b = 0)< br />{
x=a; y=b;< br />cout<& lt;& quot; stu constructor"& lt;& lt; endl;
}
and stu stu2 (1,2) were used; Definition, then x and y of stu1 are 0 and 0 respectively; The X and y of stu2 are 1 and 2 respectively; Definition, why not use stu stu2 = stu (1,2) as you say; What about it? Because the method of directly adding brackets after the class name will define a temporary object without object name, and then assign the temporary object to stu2, which is not a general initialization method (but correct). It's best to use a general method< 4. About implicit type conversion, I checked other books and found that using = is implicit and using () is explicit. The explanation is as follows:
class stu
{explicit stu (int a))< br /> ……
};
with explicit, you can only make explicit declaration: stu stu1 (3)
if not, it can be implicitly declared as follows: stu s = 3; This sentence is equivalent to converting the integer quantity 3 into a stu object. In some cases, such conversion is very dangerous. Adding explicit will eliminate this possibility. You can refer to "type conversion function" for related contents
my reference book is C + + standard library, Huazhong University of science and technology
in addition, it is necessary to study the syntax in the process of learning the language and getting familiar with the environment (such as VC + +), but after learning the concepts of inheritance, derivation, virtual function and template, we should focus on understanding the object-oriented idea of C + + and using it to solve practical problems
this is their relationship, positive solution
the problem you mentioned is that you don't understand how constructors work. If you define a constructor, use this function; otherwise, use the default constructor ( data members one by one like constructor). But the constructor you defined has only output statements, and the parameters have no default values. All initialization errors will occur
/ /
I've just experimented, and I think you still don't understand deeply enough. You did an example, compiled and passed, but didn't see the result< As a matter of fact, there are several points to be made clear:
first, a class is different from the struct in C, generally {} initialization object is not needed
MSDN help information:
compiler error c2552
& 39; identifier' : non-aggregates cannot be initialized with initializer list
The specified identifier was incorrectly initialized.
An initializer list is needed to initialize the following types:
An array
A class, structure, or union that does not have constructors, private or protected members, base classes, Or virtual functions
these types are known as "aggregates.
the class you defined has a constructor, which does not meet the above conditions. You can't use {}
2. If there is no assignment statement in the custom constructor, even if it is called, its data members X and y will only be random values (change the definition of stu2 to stu2 (1,2); If you change the constructor to the following:
stu (int a = 0, int b = 0)< br />{
x=a; y=b;< br />cout<& lt;& quot; stu constructor"& lt;& lt; endl;
}
and stu stu2 (1,2) were used; Definition, then x and y of stu1 are 0 and 0 respectively; The X and y of stu2 are 1 and 2 respectively; Definition, why not use stu stu2 = stu (1,2) as you say; What about it? Because the method of directly adding brackets after the class name will define a temporary object without object name, and then assign the temporary object to stu2, which is not a general initialization method (but correct). It's best to use a general method< 4. About implicit type conversion, I checked other books and found that using = is implicit and using () is explicit. The explanation is as follows:
class stu
{explicit stu (int a))< br /> ……
};
with explicit, you can only make explicit declaration: stu stu1 (3)
if not, it can be implicitly declared as follows: stu s = 3; This sentence is equivalent to converting the integer quantity 3 into a stu object. In some cases, such conversion is very dangerous. Adding explicit will eliminate this possibility. You can refer to "type conversion function" for related contents
my reference book is C + + standard library, Huazhong University of science and technology
in addition, it is necessary to study the syntax in the process of learning the language and getting familiar with the environment (such as VC + +), but after learning the concepts of inheritance, derivation, virtual function and template, we should focus on understanding the object-oriented idea of C + + and using it to solve practical problems
this is their relationship, positive solution
6. `35; include< stdio.h> br />-35; include< string.h> br />
typedef struct student
{
charname[10];< br />int number 1, number 2, number 3;< STU;< br />
void input(STU *stu)
{
scanf("% s" Stu-> name);< br /> scanf("% d" Stu-> numb1);< br /> scanf("% d" Stu-> numb2);< br /> scanf("% d" Stu-> numb3);< br />}
void sort(STU *stu1, STU *stu2, STU *stu3)
{
STU *stu;< br />int stuNum1 = stu1-> number 1 + stu1> number 2 + stu1> number;< br />int stuNum2 = stu2-> number 1 + stu2> number 2 + stu2> number;< br />int stuNum3 = stu3-> number 1 + stu3> number 2 + stu3> number;< br />inti, j;< br />if(stuNum1 < stuNum2)
{
stu = stu1;< br /> stu1 = stu2;< br /> stu2 = stu;< br />}
if(stuNum2 < stuNum3)
{
stu = stu2;< br /> stu2 = stu3;< br /> stu3 = stu;< br />}
if(stuNum1 < stuNum2)
{
stu = stu1;< br /> stu1 = stu2;< br /> stu2 = stu;< br />}
}
void output(STU *stu1, STU *stu2, STU *stu3)
{
printf("% s&35;92; n" stu1> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu1> number 1, stu1> number 2, stu1> numb3);< br /> printf("% s&35;92; n" stu2> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu2> number 1, stu2> number 2, stu2> numb3);< br /> printf("% s&35;92; n" stu3> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu3> number 1, stu3> number 2, stu3> numb3);< br />}
int main()
{
STU stu[3];< br /> input(&stu[1];< br /> input(&stu[2]);< br /> input(&stu[3]);< br />
sort(&stu[1], &stu[2], &stu[3];< br />
output(&stu[1], &stu[2], &stu[3];< br />
return 0;< br />}
typedef struct student
{
charname[10];< br />int number 1, number 2, number 3;< STU;< br />
void input(STU *stu)
{
scanf("% s" Stu-> name);< br /> scanf("% d" Stu-> numb1);< br /> scanf("% d" Stu-> numb2);< br /> scanf("% d" Stu-> numb3);< br />}
void sort(STU *stu1, STU *stu2, STU *stu3)
{
STU *stu;< br />int stuNum1 = stu1-> number 1 + stu1> number 2 + stu1> number;< br />int stuNum2 = stu2-> number 1 + stu2> number 2 + stu2> number;< br />int stuNum3 = stu3-> number 1 + stu3> number 2 + stu3> number;< br />inti, j;< br />if(stuNum1 < stuNum2)
{
stu = stu1;< br /> stu1 = stu2;< br /> stu2 = stu;< br />}
if(stuNum2 < stuNum3)
{
stu = stu2;< br /> stu2 = stu3;< br /> stu3 = stu;< br />}
if(stuNum1 < stuNum2)
{
stu = stu1;< br /> stu1 = stu2;< br /> stu2 = stu;< br />}
}
void output(STU *stu1, STU *stu2, STU *stu3)
{
printf("% s&35;92; n" stu1> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu1> number 1, stu1> number 2, stu1> numb3);< br /> printf("% s&35;92; n" stu2> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu2> number 1, stu2> number 2, stu2> numb3);< br /> printf("% s&35;92; n" stu3> name);< br /> printf("% d&35;92; t%d&35; 92; t%d&35; 92; n" stu3> number 1, stu3> number 2, stu3> numb3);< br />}
int main()
{
STU stu[3];< br /> input(&stu[1];< br /> input(&stu[2]);< br /> input(&stu[3]);< br />
sort(&stu[1], &stu[2], &stu[3];< br />
output(&stu[1], &stu[2], &stu[3];< br />
return 0;< br />}
7. You need to have a communication machine first, rebuild a beacon, build an area within the scope of the beacon, put the things you want to trade or sell, and then use the communication machine to select the object you want to trade. The trade is to pull the quantity bar to the left or to buy, to pull it to the right or to sell, and multiple beacons can be placed,.
8. Build a prisoner's room, then send a villain to capture TA, and then choose to try to recruit from the prisoner options
hope to adopt
hope to adopt
9. Cremation remains, scientific and hygienic, convenient and simple. After cremation, only a small box of ashes was used. The urn can be stored in a centralized way or buried in a cemetery, which not only brings convenience to people, but also saves land and wood resources and protects the ecological environment. China's traditional practice is to use coffins to hold the body after death, and then find a so-called "geomantic treasure". Cremation is a way to deal with corpses. Specifically, it is to burn corpses into ashes, then place them in urn, bury them in soil, scatter them in water or air, and even launch them into space by rocket. Cremation is popular in Hinism and Buddhism, but in Confucianism, Islam and Christianity. Since the beginning of the 20th century, cremation has been advocated all over the world to save. The skill introction makes it clear that the release range of the ring is 40 yards, that is, you can choose 40 yards as your center of gravity, team members within the circle as the release unit, while the action range of the ring is 30 yards, with your goal as the center of the circle, and 30 yards as the radius to treat the five most seriously injured units. The selection of the ring is intelligent, you only need to choose one unit, the other four. It can't be all headwear! How can they be used together! Warm travel around the world strategy to small leather hand travel network to see clearly!. Magic green dragon is equivalent to healing. When playing the third boss, press 1 to keep the boss has 3 levels of skill 1 buff (the effect of skill 1 is that the boss loses blood and the green dragon returns blood) skill 2 can rece the boss's damage skill 3 is the skill of adding blood. You need to guide and select a friendly target green dragon to lose blood and add blood to the target. This is for. In the open field, after the communication station is built, the power is connected. Click the villain, then move to the communication station, and the menu will appear. By default, you can contact four nationalities on the planet. If there is an email to prompt the trader to pass by, remember the name and contact it to trade. The main business of battle merchants is medicine and weapons, the main business of food merchants is food materials and wood, the main business of instrial merchants is metals, slaves, etc. Cremation is a way to deal with corpses. Specifically, it is to burn corpses into ashes, then place them in urn, bury them in soil, scatter them in water or air, and even launch them into space by rocket. Cremation is popular in Hinism and Buddhism, but in Confucianism, Islam and Christianity. Since the beginning of the 20th century, cremation has been advocated all over the world to save money. Frost ring itself is just a field control skill. When there are a large number of monsters out of control in PvE, or when you need to control monsters, but sheep and deep knot can't be used. You can use the ring of frost. But on the whole, the is basically useless. It takes a lot of energy for a laser to penetrate an object and heat it. It can't go out all at once. It takes a little time. As for cremation, it's a waste of energy..... Menu - control - full control mode or select reset to... Select rocker
Hot content