Programmer account notes (18)

xiaoxiao2021-03-06  81

Don't say anything, go to the topic right away (so you can say that I have a lot of mouth, haha). So what are you learning today? Knowledge is of course absorbed every day, but how much absorption is absorbed. Sometimes a small problem that looks, it can trigger other problems, all of which look at yourself, see how you treat these problems.

We are now doing an initial topic. You don't want to see less initial questions. In fact, this question I have seen it in the middle of the test questions, but different places just change it to pointers. So I also want to talk about it, in fact, most of the questions in the middle are flexible around the pointer (I don't think it as "hard", just too "flexible", it is difficult to master some, So the people in the same way we have taken the way must be well mastered.

Questions are as follows:

Read the following programs and C code, write the words of __ (n) __written in the corresponding column of the answer sheet.

[Program Description]

There is a ring having a different color numbered No. 0 to N-1, a different color of the N caps (the color of the bead color is represented by the letter, and the color of the n-grain bead is represented by the input character string). The ring is divided in the ring, and the beads on the ring form a sequence, then take the beads from the sequence as follows: First take all the continuous pairing beads from the left end of the sequence; then from the right end of the sequence in the remaining beads All continuous cohable beads were taken away, and the two of the two can be taken away from the number of beads. Cutting at different positions, the number of beads that can be taken is endless.

The procedure is obtained which position is cut on the ring, and the number of beads that can be taken away according to the above rules. The array is stored in the program. For example, 10 granular beads correspond to "AaabbBADCC", cut from the top 0 beads, the sequence is aaabbbadcc, take 3 capsules from the left end, take the 2 grain C color beads from the right end, take a total of 5 Particle beads. If the BBBADCCAAA can take 6 beads in front of the 3rd beads.

【program】

#include

Int Count (Char * S, INT Start, int end)

{

INT I, C = 0, Color = S [START], STEP = (START> END)? -1; 1;

For (i = start; s [i] = color; i = step) {

IF (Step> 0 && I> End || __ (1) __) Break;

__(2)__

}

Return C;

}

Void main () {Char T, S [120]; INT I, J, C, LEN, MAXC, CUT = 0; Printf ("Please enter the ring on behalf of different color bead strings:"); scanf ("% s ", S); len = strlen (s); for (i = maxc = 0; i maxc) {CUT = I; MAXC = C;} / * array S element loop to left moving a location * / t = S [0]; for (j = 1; j End)? -1: 1; Wonderful cooperation with the problem IF (Step> 0 && I> end || __ (1) __) Break; __ (2) __ It is not difficult to see here. SetP <0 && I

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

New Post(0)