C Language Blog Job-data type

Source: Internet
Author: User
Tags array length

First, the PTA Laboratory work Topic 1: Fall into the number of traps 1. PTA Submission List

2. Design ideas define the sum () function to calculate the number of digits received
    • Define integer variable result stores the sum of the number of members
    • for number to number=0:result+=number%10; number/=10

      Defining the main function
    • 1. Define the variable n,n_new. n indicates the old natural number n_new represents the new natural number
    • 2. Enter n
    • 3.for I=1 (i++):
    • --Calculates and outputs a new natural number N_new=3*sum (n) +1;
    • --if n==n_new, break when it falls into the trap.
    • --Assign the value of N_new to N to prepare for the next loop: N=n_new.

3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • No problem
Topic 2: Send red envelopes 1. PTA Submission List

2. Design Ideas
    • Outputs the value of money from a large to a small amount and divides it by the denomination.
3. Code

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

-No problem

Topic 3: Simple Calculator 1. PTA Submission List

2. Design Ideas
    • 1 · Define variables: ch=0 record operator, flag=0 flag error, n store value
    • 2 • Enter n to define the result initial value of n storage operation results ·
    • 3 while ((Ch=getchar ()) = = ' = '):
      --Enter operand n
      --Judgment operator switch (CH) if it is ' + ', result+=n; If for '-', result-=n; If for ', result=n; If for '/': if n==0,flag=1, otherwise result/=n; Default:flag=1
    • Determine flag:if (flag) output result, otherwise output error
3. Code

4. Problems encountered in debugging process and PTA Submission List situation description.
    • No problem
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];
Initialization: For a shorter array can be directly assigned values, such as a[2]={0,1}, for a large length can be used in the loop to assign values, such as for (int i=1;i<=1000;i++) a[i]=0;

1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?
    • The array name is the address of the first element in the array
1.3 Why use arrays?
    • Arrays can store large amounts of data and facilitate multiple invocations of several variables.
1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
    • Bubbling method: For I=0 to N, into the inner loop: for u=0 to n-1 if a[i]>a[i+1] swaps the values between the two
    • Selection method: For I=0 to N-2, the first number as the maximum number, compared to n times, compared with the following number, if the following number is large, record the value after the maximum number of exchanges.
1.5 What is the binary search method? It differs from the order lookup method?
    • For an already sorted array, take its middle position, and record the subscript. Find the right two points larger than the median, or two on the left. And so on until the condition is met
1.6 How are two-dimensional arrays defined and initialized?
    • Definition: Data type array name [integer constant expression] [integer constant expression];
    • Initialize: array name of data type [integer constant expression] [integer constant expression]={initial value}; or use loop to assign.
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. For array a[][], define an array b[][], iterate over the array A to B assignment: B[r][c]=a[c][r]; the transpose of b[][] is a[][]
    • 2. Iterate through the array and swap the value of the array a[r][c] with the value of a[c][r].

    • The number of columns in the lower triangle does not exceed the row ordinal: c<=r.
    • The number of columns in the upper triangle is not less than the row ordinal: c>=r.
    • Symmetric matrices: Traversing arrays, a[r][c]=a[c][r].

1.8 What is the general application of a two-dimensional array?
    • Can generally be applied to matrix problems.

      2. This week's content, you are not what?
    • The character array is still not quite understood.
    • The other is basically understood.

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.