C Language Data type jobs

Source: Internet
Author: User
Tags array length

First, the PTA experimental work Title 1:7-4 print diamond pattern 1. PTA Submission List

2. Design Ideas
    • 1, define M,N (used to calculate the number of spaces, output "*" number), I,j,k (for circulation)
    • 2, enter N, and let M=n (M is used in the loop to change the output of the number of spaces)
    • 3, for (i=1;i<=n/2+1;i++) the first half of the loop, output diamond Upper half
    • 4, for (j=1;j<=m-1;j++) the number of output spaces
    • 5, for (k=1;k<=2i-1;k++) output number
    • 6, end of each line, newline and M-minus 2
    • 7, for (i=n/2;i>0;i--) diamond in the lower half of the loop
    • 8, M self-increment 2 (diamond symmetry)
    • 9, for (j=1;j<=m+1;j++) output space number, note this is m+1
    • 10, for (k=1;k<=2i-1;k++) output number
    • 11. End of each line, newline

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.

    • 1, the beginning of my idea is that the upper half of the end of the first to let M 2 (because the next line has a space, with the original m output the next line will have no space), the other in addition to the number of loops and m become self-increasing the basic and the upper half of the same, but so that my output the lower half of the
    • 2, I looked at the code carefully, found that the second cycle should not be m-1, but m+1

      Topic 2:7-7 fat red envelopes 1. PTA Submission List

2. Design Ideas
    • 1, define the red envelope amount of money, and enter the amount of red packet size
    • 2, the definition of y100,y50,y20,y10,y5,y2,y1 is 100 yuan, 50 yuan, 20 yuan, 10 yuan, 5 yuan, 2 yuan, 1 yuan number
    • 3, according to the topic requirements from large to small, the amount of money from 100 to start apart, calculate the number of dollars
    • 4, according to the requirements of the title output all the number of coins

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1. At first my idea was to use loops to solve the problem, but either get into a loop of death or the answer is wrong.
    • 2, later I looked at several topics, notice the problem from large to small requirements, found that only from large to small amount of money and coins, you can get the corresponding output requirements
    • 3, also, the output format has certain requirements, the space to pay attention to good, I have begun to use is%-3d, is wrong, to use%3d to

      Topic 3:7-10 Simple Calculator 1. PTA Submission List

2. Design Ideas
    • 1. Define character op,result (calculate each step result), Number1 (store final result), number2 (all numbers except the first number are entered by it)
    • 2. Enter first number and character first
    • 3, while (op!= ' = ') Enter the next number
    • 4, if it is the case that the division sign back is zero, the output error
    • 5, if not the above situation, then the OP judgment, is the + number for the addition operation, is-number for the subtraction operation, is the * number for multiplication, is/number for division operation, is not an illegal character, output error (where result is stored in each step)
    • 6, Number1=result,number1 is the final result, to output the
    • 7, then enter the next character
    • 8. End of loop, output result number1

      3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1, initially forgot to Judge division sign after the situation of zero = =
    • 2, at first I only use result to calculate the results, Number1 is only used to store the first number, but this is only partially correct, the output of the sample is wrong

      Second, this week's topic set PTA Final ranking.

Iii. Summary of this week's study 1. What have you learned? 1.1 How is a one-dimensional array defined and initialized?
    • Define a one-dimensional array to make it clear that the array variable name, type, and size are good. Be aware that the array length should be a constant.

      1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?
    • 1.

Increment the corresponding number of bytes from the start address

  • 2, the array name is an address constant, is the first address that holds the array memory space

    1.3 Why use arrays?
  • The array has the advantages of simple expression, good readability and easy to adapt to the loop structure. Arrays are easier to understand when you need to express a large number of variables of the same type.

    1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
  • 1. Selection Method:
  • Starting from the first number for (k=0;k<n-1;k++)
  • Compares a number to other numbers for (i=k+1;i<n;i++)
  • Compare the minimum and first number when comparing the IF (A[i]<a[index])
  • And then the next number, compared to the subsequent number, so loop until the last number
  • 2. Bubbling method:
  • for (k=0;k<n-1;k++) max=k
  • for (i=0;i<n-1-i;i++) the first number is compared with the following number in turn
  • if (A[i]>a[max]) Exchange two numbers, storing large values in A[max]
  • 3. Direct Insert Sort
  • for (k=1;k<n-1;k++) j=k
  • for (i=k;i>0;i--) I must start from K
  • if (A[j]<a[i-1]) swaps the values of both

    1.5 What is the binary search method? It differs from the order lookup method?
  • 1, the binary search method is the number to be found and the array in the middle of the comparison, in order to narrow the boundary until the location of the number to find
  • 2, binary search method for ordered array, the advantage is that the search speed is fast, and sequential lookup method is slow, but when the array is unordered, can not apply the binary search method

    1.6 How are two-dimensional arrays defined and initialized?
  • 1, two-dimensional array includes array type, array name, array row and column length
  • 2, the branch assigns the initial value, the order assigns the initial value

    1.7 How is the matrix transpose implemented? In the matrix: the relationship between the row label I of the lower triangle, the upper triangle and the symmetric matrix J? Please state.
  • 1, the main diagonal for the boundary, the ranks of the interchange
    -2, Lower triangle: i>=j, Upper triangle: i<=j, symmetric matrix: i==j

    1.8 What is the general application of a two-dimensional array?
  • Mainly used to represent two-dimensional tables and matrices

    2. This week's content, you are not what?
  • 1, the problem understanding is not enough, easy to make some small mistakes
  • 2, for the application of the array, the feeling is not very understanding, the use of unskilled
  • 3, for the data sort, not very clear, understanding is not thorough

C Language Data type 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.