Programmer account notes (5)

xiaoxiao2021-03-06  106

Today is the last day of discrete school, my grades, of course, I will not get rid of it, it is also very likely to be the first (countdown). I blame myself, but I can't quit. Because the school's original computer curriculum is also a lot, all are in teaching graphics, what PS, CW must go to the class, it is a bit uncomfortable.

Ok, don't say too much of your own school's shame. Then let's learn today's knowledge, many friends are I am typing all day, but I don't think that these are not a lot of time, and more than the benefits (I have listened to the morning, I was reviewed at night.). The reason is that there is a cloud "Wen Zhizhen New", I think this sentence is especially reasonable, because I can never see the teacher in the classroom in the classroom. Ok, I still talk about today's learning. Yesterday, we replied, I was busy yesterday, but today I suddenly remembered the rushing to do, this is a question:

Give one not more than 5 digits, require: 1, this number has several bits 2, printing each bit, 3 reverse print, such as 321 output 123.

It's not difficult to say this, I have finished it for a while.

Main ()

{

Int n; int Num;

INT i = 0, A [5];

Printf ("Please enter a positive intent of 5 digits");

Scanf ("% D", & num);

DO

{

Do [I] = NUM% 10;

Num / = 10;

i ;

} while (NUM! = 0);

n = i;

Printf ("len% d", n);

For (i = N-1; I> = 0; I -)

Printf ("% d", a [i]);

For (i = 0; i

Printf ("% d", a [i]);

}

When I did this question, I also used the drawing method of Yesterday, but I still have to go to you, so you can work with the program. All of us have each way, some are very long (with Switch statement), I don't know what he thinks, but the different people have different thoughts is correct, and the programming this has no complete uniform answer. So what do you think of do you have any ways to do it, okay, just do it for five minutes. ... well, time is here, let's talk about my other classmates, and he uses the array of characters, and it is very simple and convenient. What happened to you? If you have a good method, you can communicate, because I wrote these for everyone (also for yourself). Everyone should understand my procedure, because my thoughts are so simple.

The teacher said that after the job yesterday, the teacher began to say the course to be told today. Today's theme is a loop statement, in fact, is it only such a cycle statement in the C language? Compared to QB, it is really a big scene, because QB in order is a seven or eight kinds of cyclic statements, as for those who I don't know too clear. Then tell the C language below. There are three kinds of C language circular statements, let's talk more simple first two!

While (condition) {statement;} and DO {statement;

While;

Here I want to repeat a joke that the teacher gives us, that is, there is a little girl asking her mother to launch a little story. There is a very embarrassing little girl, always asking her mother, can't eat sugar. If you have to approval, take a piece to eat. However, she took a piece of eating, and she asked my mother, I couldn't eat sugar. If it can, it will continue to eat, otherwise it will not be allowed, but there is already a piece of mouth. This is just the two cycle statements, the first loop statement is the first nimest condition to continue, otherwise exits. The second is that the procedure inside the direct movement is first, followed by the conditions to see if it can continue to run again. Ok, these two more simply look at a unique for loop statement in the C language. This loop is particularly special, such as the fifth day, a structure is also particularly special, and three expressions are very flexible. Just give a program for everyone to see: int i = 0; for (;;) IF (i > 10) Break; printf ("% d", i); this says how much here i? It is related to this operator with incremental operators, there can be two ways, one is i as above, as for the other is i, the answer is equal to 12, while the latter Equal to 11. Here is because is incremented by two ways, then we have to master this, try your own machine. Another program is good to see this incremental operator: INT i = 0; if (i ) Printf ("a"); / * If here is true to output a * / else printf ("b"); / * Otherwise, it is to output B * / you can try it. Is it clear that this increasing principle is, let's talk about it, in fact, I , this is the first i comparison, it is more than 0, so it is naturally 0 The result is of course to output B, then the i will first compare i plus 1, then it will output A, ok, then increment and --decrement is the same nature. However, it is important to note that the two incremental decrement operators are to be variables, and they cannot operate with constant. Ok, I have finished the loop, of course, I have to know how to use it! So the teacher will go out to make us think about it, but I believe that some people have studied, that is, "Magic Cube", but the teacher said that although this Rubik's Cube, there is a direct algorithm, but to let We think that this question is to do this, use the computer's ability to complete, but seeing so many numbers to align, the loop is not to say much, so I can't think of it at all (start dizzy). Finally, there is no one can make it. I have to listen to the teacher, but the teacher is not fully finished, just gave us a structure, such as the fifth day, the second, let us have interested, I will complete it, I have mathematics this Things have not been Feel. Ok, then continue the second question, it is also a problem of arrangement. You should have the "second edition of the C-program language in your hand", then please turn over the book to page 121, 6.15 questions, this The title is to arrange the topic of the combination. This is actually a rule that can be found, but it is not what we find but the teacher gives us, today, this class really has too many problems, at least for me. Below I have no good mouth, I have to show the teacher's method, such as the fifth day, the three programs are also under.

Char XYZ [] = ['x', 'y', "z '; INT I, J, K; For (i = 0; i <3; i ) for (j = 0; j <3; j ) IF (j == i0 continue; for (k = 0; k <3; k ) IF (k == i || K == J) Continue; Printf ("A-% C / N", XYZ [i] PRIHTF ("B-% C / N", XYZ [J]); PriHTF ("C-% C / N", XYZ [K]);

Let everyone understand itself. Ok, today my head is also particularly halo, shoulder also special acid. But I still have to work hard!

转载请注明原文地址:https://www.9cbs.com/read-124135.html

New Post(0)