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 (to submit list, not result)

2. Design ideas (in code to indicate the deduction points)
    • First enter a number to determine whether it is 1 special case, if it is directly output.
    • Instead of first entering a for loop from 1 to this number, the loop variable I minus 2 goes into a For loop output that decrements with the loop variable i to know I=1.
    • For the end of the line can not have a space problem as long as the second loop to determine when the other output number I=1 no space at the end.
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

4. Problems encountered in debugging process and PTA Submission List situation description.
    • More output of one of the middle largest numbers.

      Through debugging know is in the first loop out after the loop variable i input more than the value of one, and then the value of I minus two, is correct
Topic 2: The number falling into the trap 1. PTA Submission List (to submit list, not result)

2. Design ideas (in code to indicate the deduction points)
    • Define a function that computes each digit and multiply 3+1, enter the first number into the For loop in the main function, first call the function to calculate the value to the result, and determine whether the preceding number is equal to exit the loop, not then call the function loop calculation until there are two values equal.
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

4. Problems encountered in debugging process and PTA Submission List situation description.
    • At first I always wanted to complete all the procedures in the function, but later found it troublesome

    • Then change the idea, use the function to calculate the value returned to the main function in the main function with a duplicate assignment, then call the function calculation, and then compare two values is equal to solve the problem

Topic 3: Judging the legal identifier 1. PTA Submission List (to submit list, not result)

2. Design ideas (in code to indicate the deduction points)
    • Enter the value of repeat first to absorb the carriage return with a GetChar
    • Use the For statement to perform a repeat operation, so that flag=0 and GetChar enter the first character to determine whether to start with a letter or an underscore
    • Instead of entering a while loop, repeat the input of the remaining characters and make the flag++ jump when the input carriage returns, judging if flag is 0 or not 0 output no
    • is to start with a letter or underscore, enter a while loop to repeat the input of the remaining characters and determine if the character is an alphanumeric or an underscore is to continue to enter the remaining characters, not the flag++, enter the end loop, in the end to determine whether the value of flag is zero output yes or no
3. Code (note,,,. Do not paste on the blog. No need to use ... syntax to render)

4. Problems encountered in debugging process and PTA Submission List situation description.
    • 1. Start without the input repeat value after the return of the absorption, resulting in a direct jump out

    • 2. No flag data reset results in flag not being 0, output is no, old fire

    • 3. Format error is because there is no line break ...

Second, this week's topic set PTA Final ranking. (2 points)

Iii. Summary of the study this week (3 points) 1. What have you learned? 1. How do one-dimensional arrays be defined and initialized?

Definition: Type an array group name [array length]
Initialize: Type an array group name [array length] = {initial value table};

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

Memory structure

The array name is the name of the array variable and is a valid identifier

1.3 Why use arrays?

Using an array in a program allows a group of variables of the same type to use the same array variable name, with the advantage of being simple to express, readable, and easy to use for looping structures.

1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
    • 1. Bubble method: Enter the number of elements of the array, through a for loop input all elements, with nested loops, outer loop control sort the number of passes, n number row n-1, the inner loop for each trip of the comparison number (with the increase of the number of external cycles to reduce), using if to compare adjacent elements, reverse order is exchanged, Finally, a for loop is used to output the sorted result.

    • 2. Selection method: First enter the number of elements of the array, after a for loop input all elements, with nested loops, the outer loop control the number of times, n the number of selected n-1, assuming that the first number of the current trip is the maximum value, in K, from the next number to the last number to find the most value if there is a greater than the maximum, , if K is not the initial I value, the description after which a larger number is found, the interchange maximum and the first number of the current sequence, and finally a for loop to output the sorted result.

    • 3. Direct Insertion Sort: First enter the number of array elements, through a for loop input all elements, with nested loops, the outer loop control the number of times, n number from the 2nd number to the end of a total of n-1 inserts, the number of inserts to be staged in the variable T, in the ordered sequence (subscript 0 ~ i-1) to find the insertion position, If the insertion position is not found, the current element moves back one position, finds the insertion position, completes the insertion, and finally outputs the sorted result with a for loop.

1.5 What is the binary search method? It differs from the order lookup method?
    • When comparing an array, compare the median of the array size, and when the data is found to be larger than the center data, compare it in a later interval.

If it is smaller than the center data, it is compared in the previous interval, and in the new interval, the previous size intermediate comparison method is used again to compare until the data is finally found.

    • The sequential lookup method starts at one end of the table, and the dichotomy begins in the middle.
1.6 How are two-dimensional arrays defined and initialized?

Definition of a two-dimensional array: Type an array group name [line length] [column length];
Initialize: 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 indicate
    • Upper triangle: i<=j
    • Lower triangle: i>=j
    • Main diagonal: I==j
    • Sub-diagonal: i+j==n-1
1.8 What is the general application of a two-dimensional array?
    • Applied to the matrix aspect
2. This week's content, you are not what?
    • For this week's mid-term exam, I am very dissatisfied with the feeling of leaving the computer to write programming problems a bit inadequate, will always miss some things, for textbook knowledge mastery or not skilled, not seriously read textbooks, after class did not seriously review the consolidation
    • For the 9th question of the PTA played for a long time or feel the code out of chaos, and sometimes confuse themselves
    • For the direct insertion sort, it's still a little unclear.

C Language Blog Job-data type

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.