C Language Blog Job-data type

Source: Internet
Author: User
Tags array definition array length

One, PTA experimental work 1:7-2 Location Code Input Method 1. PTA Submission Record

2. Design Ideas

3. Code

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

Originally this problem to see the topic I was panicked, thought it was difficult and then continue to look down to see this

Suddenly, after writing the code, the following questions appear:

is the high-byte and low-byte output order is wrong, the order is good.

Topic 2:7-6 the number falling into the trap 1. PTA Submission Record

2. Design Ideas

1. Define a function trap that calculates the number of traps;
2. Define three variable i,number,n, enter the value of number;
3. Enter the loop: I=1, when i>0, N=number,number=trap (number), output I:number, when N=number, the program ends; no, then i++, continue the loop.

3. Code

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

Compilation error is because there is no thought before, write half stuck, first submitted to do something else.

The reason for this problem is that I put the end condition of the loop on the outside.

Topic 3.7-10 Simple Calculator 1. PTA Submission Record

2. Design Ideas

3. Code

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

The first error is if the condition inside the if only uses an equal sign, check for a long time to find

The second time is to determine the output "error" condition with the flag=0, reversed, changed to Flag=1, the output error can be.

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?
    • Definition: Type an array group name [array length]; Array length is a constant
    • Initialize: Type an array group name [array length]={initial value table}, e.g. Inta a[10]={1,2,3,4,5,6,7,8,9,10}

      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?

You can reduce the hassle of defining variables and facilitate the invocation of data.

1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
  • Sorting by Selection method
    Defining an Integer variable i,index,k,n,temp,index the subscript where the minimum value is stored
    Define Array a[10]
    Input n
    I=0
    When i<n, input number, I increment
    Assigns the number of inputs to the N elements of array A in turn
    K=0;k<n-1, use index to store the lowest value subscript
    Determining the size of elements and A[index] in array a
    If a[i]<a[index],index=i, the smallest element is exchanged with the element with the subscript K
    Temp=a[index];
    A[INDEX]=A[K];
    A[k]=temp;
    The value of the n array element after the output is drained.
  • Bubble Method Sort
    Define Array A[n]
    Defining integer Variables I,j,temp,n
    I=0
    When meeting i<=n-1
    Number of inputs
    i++
    Assign this set of data to a[n] in turn
    Judge the two adjacent data, if A[J]>A[J+1]
    TEMP=A[J]
    A[J]=A[J+1]
    A[j+1]=temp
    A process like this has to repeat n=q-i times.
    Outputs a new array after the loop ends.
  • Sort by direct insertion
    Define Array A[n]
    Defining integer Variables I,j,k,temp
    i=0;
    When meeting i<=n-1
    Number of inputs
    i=0;
    Temp indicates the minimum value of the corner label
    Determine the size of data a[j] and TEMP
    If Temp<a[j],a[j]=temp
    Using a[k+1]=a[k] To move the data to the right after the insertion position
    Repeats n-1 times, outputting a new array.

    1.5 What is the binary search method? It differs from the order lookup method?
  • Find in a set of ordered numbers, pass the corresponding data, compare the same data as the metadata, and then return the corresponding array subscript
  • Difference: Sequential lookups are characterized by a search down from the first element, and if the element is consistent with the target, the lookup succeeds if there is still no target element to the last element, then the lookup fails. The binary lookup is to find the target element from the middle of the table, if a consistent element is found, and if the intermediate element is smaller than the target element, the second half of the table is searched, and the middle element is larger than the target element, then the first half of the table is looked up.

    1.6 How are two-dimensional arrays defined and initialized?
  • Two-dimensional array definition form: Type an array group name [length of the line] [column lengths].
  • Initialization
    (1) Initial value of branch assignment
    General form: Type an array group name [President degree] [column length]={{initial value table 0},..., {{Initial value table k},...}
    Assigns all the data in the K in the initial value table to the element of the K row in turn.
    (2) Sequential assignment method
    General form: Type an array group name [President degree] [column Length] = {Initial value table}
    The data in the initial value table is assigned to the element sequentially, based on the order in which the array elements are stored in memory.

    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.
  • Matrix Transpose: With the main diagonal as the axis of symmetry, all elements are swapped position;
  • Lower Triangle:i>=j;
  • Upper Triangle:i<=j;
  • Symmetric matrix: i==j;

    1.8 What is the general application of a two-dimensional array?
  • Two-dimensional table
  • Matrix

    2. This week's content, you are not what?
  • string input and judgment is very difficult, only a very few cases of the topic I can write, generally do not write ...
  • The binary operation is a bit rusty.
  • For the understanding of the two-dimensional array of fuzzy, use up jerky.

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.