C Language Blog Job-data type

Source: Internet
Author: User
Tags array length

First, the PTA experimental work Title 1: Inverted number string 1. PTA Submission List

2. Design Ideas
    • Defining Variables N,i,j
    • Input n
    • The value of I for 1 to N, output I, if i<n, then output space, I self-increment
    • The value of J for N-1 to 1, the output space, and then the output J,j auto minus
    • Returns 0
3. Code

4. Problems encountered in commissioning process and PTA submission List status note


Found out two out of 6

Because J has an initial value of N, it also repeats the output of a 6

Topic 2: Print diamond pattern 1. PTA Submission List

2. Design Ideas
    • Define variables ....
    • Enter a value to deposit N
    • First cycle print 1~ (n+1)/2 lines of pattern
    • A=n+1-2i,b=2i-1
    • Value of J for 1 to a output space
    • Value of K for 1 to B output * and spaces
    • Line break End
      -Second cycle printing (n+3)/2~n line pattern
    • c=2i-n-1,d=2(n-i) +1
    • Value of L for 1 to c output spaces
    • Value of M for 1 to D output * and spaces
    • Line break End
3. Code

4. Problems encountered in commissioning process and PTA submission List status note


Run found with the PTA pattern, but the submission has appeared in a format error, seriously see the topic found each * behind all the space, too inertial thinking
And then change the code or the format error, enter 3 discovery

Problem with pattern printing on second cycle
Debug the second loop with 3

found that the value of C is a negative number ... In the draft of the input 7 as a special case to write code resulting in a non-universal, should correct the assignment of C

Topic 3: The number falling into the trap 1. PTA Submission List

2. Design Ideas
    • Defining variables
    • Enter a number to deposit N
    • The value of I for 1 to a number (exit loop when n=n1)
    • Assign N to m and number
    • Just number!. =0,number=number/10,n self-increment, end of loop n
    • Value of J for 1 to N, a=m%10, m=m/10,sum=sum+a,j increment first to sum value
    • N1=sum*3+1, get a new number N1
    • Output i:n1
    • If the n=n1 exits the loop directly, otherwise assigns the N1 to N, assigns the sum to 0, and wraps the end.
3. Code

4. Problems encountered in commissioning process and PTA submission List status note


The first time into the dead loop and has not changed line, and the number of bits n to calculate n the loop on the outside, so the value of n is not changed, I modify

Correct format after correction but not right from the second number

found that the value of sum after the first loop is not 0, will continue to add, after the cycle to sum ' assigned to the value of 0

Second, this week's topic set PTA Final Ranking

Three, this week study summary 1.1 how a one-dimensional array is defined, initialized
  • 1. Define an array to specify the variable name of the array, the type of the array elements and the size of the arrays, the general type is the type an array group name [array length].

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

  • The array name is an address constant that holds the first address of the array memory space

    1.3 Why use arrays?
  • The amount that the value can change during the program's run. In fact, the variable is a small memory of the name, the size of the memory is determined by the type of the variable, but also determines the size of the memory can be stored in the range of data

    1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo-code display. Selection Method:
  • For 0 to N-1 control the number of outer loops
  • Make k=i for i+1 to n find the maximum value in the next number to the last number
  • If there is a larger value then K=j
  • Otherwise with Temp=a "K", a "K" =a "I", a "I" =temp exchange position

    Bubbling method
  • for 0 to N control the number of bad times
  • Number of loops in for 0 to N-j
    -if this number is greater than the next number, then use Temp=a "I", a "I" =a "i+1", a "i+1" =temp to Exchange position

    Insertion method
  • The value of I for 1 to n controls the number of outer loops
  • The value of J for I-1 to N
  • Temp=a[i],a[j+1]=a[j],a[j+1]=temp to insert

    1.5 What is the binary search method? It differs from the order lookup method?
  • Assuming that the data is sorted in ascending order, for a given value x, a comparison is made from the middle of the sequence, if the current position value equals X, the lookup succeeds, and if X is less than the current position value, the first half of the sequence is searched, and if x is greater than the current position, the second half of the series is searched until it is
  • Higher efficiency relative to sequential method

    1.6 How are two-dimensional arrays defined and initialized?
  • Type an array group name [line length] [column Length] = {{Initial value table 0},...,{initial value table K} ...}

    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.
  • i<=j; symmetric matrix i=j of upper triangular i>=j; in lower triangle

    1.8 What is the general application of a two-dimensional array?

    Applied to certain elements that have certain positional logic, such as matrices

    2. This week's content, you are not what?
  • A variety of sorting methods are not fine, although the algorithm logic can be thought out, but once the code to knock out is another condition

C Language Blog Job-data type

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.