C-language two-dimensional array jobs

Source: Internet
Author: User

First, the PTA Laboratory work Topic 1:7-3 Year of birth 1. PTA Submission List

2. Design Ideas
    • 1. Declare a function different () to calculate the number of different numbers for a year
    • 2, define Y (Y is to calculate the amount of years to meet the requirements), N (n is the number of different numbers required by the title), X (x to hold the starting year), flag (flag is used to denote the number of different numbers of each Y value)
    • 3, enter the beginning of the year Y and the title required n
    • 4, X=y (storage start year)
    • 5, do {flag calculates the number of different numbers in Y, if flag=n, conforms to test instructions, outputs the corresponding result, and ends the loop; if not, y increases by one}while (1)
    • 6. Define the function different (y):
    • First define an array a[4] and the number of different numbers count equals 4;
    • A[4] Store every bit of y;
    • for (int i=0;i<4;i++) {for (int j=i+1;j<4;j++) if A[i]=a[j,count minus one, ends the loop of J;
    • Function results return count

      3. Code


4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1, the title requirements of less than 4 years to be in front of 0, a start do not know how to output, Baidu after understanding as long as the output in the use of%04d can make insufficient front of 0
    • 2, the function of J in the Loop, if the a[i]=a[j,count minus one, it is necessary to immediately end the cycle of J; I missed the end loop so that count will be reduced several times when the year is not four bits

      Topic 2:7-7 Find Saddle point 1. PTA Submission List

2. Design Ideas
    • 1. Define two-dimensional array a[6][6] and N
    • 2. Enter n
    • 3, for (i=0; i<n; i++) for (j=0; j<n; J + +) {scanf ("%d", &a[i][j]); Enter two-dimensional array
    • 3, the definition of k=0,q=0,p=0 (K,q,p are the following cycle to use), flag=1 (flag is to judge the existence of the saddle point)
      -4, for (i=0; i<n; i++) {q=i (the following need to determine whether the maximum value of this row is the lowest value); }
    • 5, for (p=0; p<n; p++) {if (a[i][k]<=a[i][p])//array element comparison, if greater than a[i][k], the array column is assigned to K K=p;}} This finds the row maximum and assigns the value of the column that contains the maximum value to K for the next row to find the minimum value
    • 6. for (J=0; j
    • 7, when found only to compare I and j is equal, equal to indicate that the maximum value of this row is the minimum value, so that flag equals 0, end loop
    • 8, if (flag==0) output result else output None
3. Code


4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1, the cycle at the beginning, must let q=i, otherwise the saddle point in the last time will be wrong
    • 2, there are a lot of loops here, I often output errors after the change code accidentally deleted some loops of curly braces, resulting in a compilation error = =

      Topic 3:7-10 Yang Hui triangle 1. PTA Submission List

2. Design Ideas
    • 1. Define Array A[10][10].i,j,n
    • 2. Enter n
    • 3. for (i=0;i<10;i++) 1 (a[i][i]=a[i][0]=1) in the wardrobe and diagonal
    • 4. for (i=2;i<n;i++) {for (j=1;j<i;j++) {}a[i][j]=a[i-1][j-1]+a[i-1][j];//The number of the third row}} is stored in the third row, except for the diagonal number
    • 5. Output array

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1, I start with the J is less than or equal to I, the result of the number of diagonal changes
    • 2, the first time I forgot to change the line, the output error

      Second, this week's topic set PTA Final ranking.
Third, peer code peer review 1. Peer evaluation of the names of students

Li Yucheng

2. My Code, mutual evaluation of the student code
    • My Code

    • Hu Cheng Student Code

3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer? If the classmate code is wrong, please help to point out where the problem.
    • Hu Cheng is to accumulate by using a variable diff, and I will assign a value to the 1 element first, then the middle number is added by the rule array.
    • I might prefer to Hu Cheng classmate's code, because its code is relatively short, the use of the loop is less (my personal loop more prone to chaos)

      Iv. Summary of this week's study (3 points)
1. What have you learned? How do I store strings in 1.1 C?
    • storing strings using character arrays

      1.2 What is the end flag of a string and why do you want to end the flag?
    • End sign for ' + '
    • The end flag is used to determine whether to end the loop

      1.3 What are the methods for string input?
    • 1, direct input, such as a[5]={"Happy};
    • 2, using the SCANF function, the format control is%s, the input parameter is the character array name, the return or the space end
    • 3, using the gets function, the input parameter is the character array name, the return end

      1.4 Numeric characters How to turn an integer, write a pseudo-code?
    • 1, number single conversion: Numeric characters-' 0 '
    • 2. Multi-bit conversion:
      -1. Define the loop variable i,sum=0
      -2.i=0
      -3.while (a[i]!= ') sum=sum*10+ (a[i]-' 0 ')
      -4.i++

1.5 16 binary, binary string how do I turn 10 binary? Write pseudo-code?
    • 1, 16 binary
      -1. Define the loop variable i,sum=0
      -2.i=0
      -3.while (a[i]!= ') if (A[i] is a numeric character) sum=sum16+ (a[i]-' 0 ') if (A[i] is a-f) sum=sum16+ (a[i]-' a ' +10) if (A[i] is a-f) sum=sum*16 + (a[i]-' a ' +10)
      -4.i++
    • 2, 2 binary
    • 1. Define the loop variable i,sum=0
    • 2.i=0
    • 3.while (a[i]!= ') sum=sum*2+ (a[i]-' 0 ')
    • 4.i++

      2. This week's content, you are not what?
    • 1, although the basic grasp of the array, but the use of it is not skilled
    • 2, the use of arrays often have to use a lot of loops, causing me to often confuse the amount of the loop (even if there are comments often do not notice = =)
    • 3, although can understand the sequencing method, but for its application is not skilled

      3. Midterm Summary 3.1 Why do you think you didn't do well?
    • 1, my choice has only 8 points, this shows that my basic knowledge is not solid enough to read more textbooks, to strengthen the understanding of basic knowledge and control
    • 2, my correction is not very good, mainly some logic errors can be seen, but do not know how to modify, this point I think it should only through more problems to increase experience to solve
    • 3, programming problems I do well, but in some of the mathematical formula for the cause and effect of the application, I am prone to short-circuit (for example, the second problem of programming, I do not actually forget how to solve x =), I think this may have psychological factors, perhaps a few months have not experienced the exam a little nervous, this point to overcome
    • 4, fill in the code of the topic although do can, but some simple place but wrong, this is not should, investigate its reason, I think it is the basic problem, to return to the textbook, master the simplest knowledge

      3.2 List the wrong questions. Please select the question, fill in the blanks, change the wrong question, the programming question to give a question to explain why wrong, how to change?
    • 1. Select the question:

The first question I understand the meaning of the wrong, I thought he asked the C language can output the number of the binary bit = =

    • 2, fill in the blanks questions:

The seventh empty for Ch=getchar (), I only wrote CH, this is I did not take the course content fully understand the reason, after finishing the lesson I should carry on the review

    • 3, change the wrong question:

Change the wrong more embarrassing, because I know it is wrong, wrong, but do not know how to change, I think this is because I read the process is not enough reason, I want to read more programs, learn to see the program

    • 4. Programming Questions:

The other two problems of programming I do well, this question I also know how to do, but may be more nervous exam, I forgot how to ask x value = =, the time of the exam is more urgent, did not think carefully, I hope the next problem can keep a clear mind, do not worry

3.3 The second half semester how to adjust C's study?
    • 1, the basic knowledge should be mastered first, that is, the content of the textbook first proficient, and then to talk about further esoteric content
    • 2, through the mid-term, I understand that the C study is not just a PTA programming problem, some basic theory of simple knowledge to understand
    • 3, the second half of the semester, to do a good job in the basic knowledge of the situation, the use of these knowledge in programming

C-language two-dimensional array jobs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.