A C program question, please help you!

Updated on educate 2024-05-24
8 answers
  1. Anonymous users2024-02-11

    Will you be too old to see clearly? This is the overload of the constructor, which is when I instantiate.

    menumodel newmodel=new menumodel();This is an empty object, and what he executes is public menuModel().

    This function, if instantiated, is written like this:

    menumodel newmodel=new menumodel();

    menumodel newmodel2=new menumodel(newmodel);

    Then he will execute the protected menumodel (menumodel model).

  2. Anonymous users2024-02-10

    If there is no custom constructor, the system will automatically generate a default constructor with empty parameters, and if you define your own constructor in the class, the system will not generate an empty constructor, and the programming language requires that it must contain an empty constructor.

  3. Anonymous users2024-02-09

    If you don't have a default method in this class, and you don't write a new method to this class, then you're going to make an error when instantiating this class, and you're giving you one by default to prevent errors.

  4. Anonymous users2024-02-08

    It means that it has been added twice, and my understanding is like this:

    Clause. 1. When the cycle ends, k is added at the end, so it should be at least k-1;

    Clause. Second, because it is the while(bool) loop in the while loop, this loop has a characteristic that it loops first and then judges, which means that it will execute the loop at least once regardless of whether the conditions are met or not, so in the end, s has exceeded 2000 before stopping the loop, so that k adds one more time, and it is another k-1.

    To sum up, we can get K-2.

  5. Anonymous users2024-02-07

    It should indeed be K-2

    while (s < 2000) If s is less than 2000, it means that the cycle has been overrun, so here you need to subtract 1 for the first time;

    And the purpose of subtracting 1 this time is to turn k into a number before k++.

    When s < 2000, in fact, for k at this time, s = s+(k-1)*(k-1);

    So when you finally return, you need to put the last K-2;

    For example; int s=0,k=1;

    while(s<6)

    1st round k=1; s=1 when the round ends, k=2, second round, k=2:s=5, when the round ends, k=3, third: k=3; s=14.

    At the end of the fourth round, k=4, the end loop k-1 simply returns k to 3 (i.e., the initial value of the third round), but the calculated s of this initial value is equal to 14 and does not satisfy the cycle condition, so it needs to be subtracted by 1

  6. Anonymous users2024-02-06

    Just write k, that's wrong.

    int k = 1, sum = 0;define variables and initialize while (sum < 2000) using while constraints); The maximum k value of the print satisfies the relation.

    Let the page stop.

  7. Anonymous users2024-02-05

    I think it's supposed to be K-1;

    How is it K-2?

  8. Anonymous users2024-02-04

    This equation is equivalent to (n++)n--)n, and the self-increment and self-decrement operations placed after the variable are performed after the value of the expression is calculated.

    So, the value of the expression is equal to n+n-n, and the result is equal to n.

    After calculating the value of the expression, we can increase and subtract n by adding and subtracting, and the value of n remains unchanged.

Related questions
10 answers2024-05-24

1. The time is equal, the difference between the first time and the second time is 42-24=18km The first time against the water and the second time is 14-8=6km, from which it can be seen that the speed of the water is 18 6 = 3 times that of the water, so if it is all along the water, you can go 42 + 8 * 3 = 66km in 11 hours, that is, the speed of the water is 6km, and the same is calculated that the speed of the water is 2km, and the average speed of the water and the water is the speed in the still water, that is: (6 + 4) 2=5. The water speed is Shunshui - hydrostatic speed = 6-5 = 1km >>>More

13 answers2024-05-24

I'll give you the answer? Or a hint!

Question 1, I can't figure it out like that, I'll break it down one by one, the first one is 1-1 2, the second one is 1 2-1 3 in turn. The last one is 1 2009-1 2010 The answer comes out right away: 1-1 2010 = 2009 2010 >>>More

6 answers2024-05-24

Assuming that the unit price is not the unit price without tax, if the unit price including tax you can work backwards, don't say that you won't ......Buy buttons. Borrow: Raw materials 30 >>>More

11 answers2024-05-24

In this text, (bac) (acd) is used instead of angangle bac and acd >>>More

7 answers2024-05-24

In 1953, Miller simulated the primitive earth's atmosphere and found that under the action of thunder and lightning, these inorganic atmospheric components can be synthesized into organic amino acids and other constituent components of life, thus providing an experimental basis for the theory of life autopoiesis. However, the above discoveries not only do not support this theory, but are skeptical of the above theory to a certain extent, because amino acids and other organic matter have also been found in the universe outside the earth, and at that time, these "small stars" containing amino acids were very likely to bring these organic matter and even life to the earth through collision or fall on the earth's surface, so the origin of life on the earth is still a scientific puzzle whether the earth was born on earth or came from other places. However, I am more inclined to the autopoiesis theory, because the theory of cosmic life (which holds that life on earth comes from the universe) does not fundamentally solve the problem of the origin of life, because if life on earth comes from the universe, then what about the life of the universe from **? >>>More