C Language Blog Job-data type

Source: Internet
Author: User
Tags array definition array length

First, the PTA Experimental work topic 1:7-6 fall into the number of traps 1. PTA Submission List

2. Design Ideas
  • 1. Define the input variable n, output number I, determine the variable x, and the first set of J
  • 2. Enter n, and attach an initial value of 0 to I to calculate the first J
  • 3. Using Do-while (X!=J) in the cycle
    Every time i++,
    Output i,j
    and make X=j
    J=skt (x);//Call function
  • 4.//output is required if the input is not a trap number i+1
    printf ("%d:%d\n", I+1,j);}
    Custom functions: (The implementation of the first sum of their numbers, and then multiply it by 3 plus 1, into a new natural number N)
  • 1. Define the variable x as the input value, SUM and N to return the value of the main function
  • 2. Using while (n!=0) {
    Take out each bit number
    Accumulate to sum
    Give the sum*3+1 to n
    Returns n to the main function

    3. Code

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


    Can not enter the next cycle, in the loop to attach the initial value of I, to J to find the first time and then enter the cycle
    The list part is correct only for the first result.

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

    2. Design Ideas

  • 1. Define the number of ABCEDFG used to represent each denomination, and X for the amount
  • 2. Enter X
  • 3. Calculate separately
    a=x/100;//100 Yuan Number
    b= (x-a100) Number of/50;//50 yuan
    c= (x-a
    100-b50) Number of/20;//20 yuan
    d= (x-a
    100-b50-c20) Number of/10;//10 yuan
    E= (x-a100-b50-c20-d10) Number of/5;//5 dollars
    f= (x-a100-b50-c20-d10-e5) Number of/2;//2 dollars
    g= (x-a
    100-b50-c20-d10-e 5-f*2) Number of/1;//1 dollars
  • 4. Output denomination and number of sheets by format

    3. Code

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

    The debugging process did not encounter any problems,
    PTA Submit display format error, for no control digit alignment

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

    2. Design Ideas

  • 1. Define the character variable ch
  • 2. Define x=0 as the input value for the judgment variable N, I is the middle value of each operation
  • 3. Use the while (ch!= ' = ') loop, then enter N in the loop and the character use the If-else if statement to select the equation, and then divide the operation if the divisor is 0 will x=1 and break
  • 4. If there is an illegal operator x=1
  • 5.x!=1 output I if x==1 output error

    3. Code

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


    No judgment is made on the case that the divisor is zero and the illegal operator

    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?

    One-dimensional array definition requires explicit array variable names, array element types and arrays, in general form: type name variable name [array length]
    When an array is initialized, the array element is assigned an initial value, in the general form: the type name variable name [array length]={initial value table} (can only be for partial elements)

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

    Structure as shown in Figure 7.2 of the textbook 150 page
    The array name represents the address of the first cell in the contiguous memory space allocated by the array

    1.3 Why use arrays?

    Arrays allow a set of identical types of data to be arranged in an orderly manner and stored continuously for ease of use.

    1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo-code display. Selection Method:
  • 1. The n elements of an array are appended with the initial value
  • 2. To sort n elements with a for
  • 3.a[i]<a[min] Two value is exchanged
  • 4. Return the a[min]
    Bubbling method:
  • 1. Defining the variable A[10],i,j,k
  • 2. Once the number of input array
  • 3. Sort n number, for (k=0;k<n-1;k++) max=k
  • 4. Output n The value of the number of elements of the array
    Direct Insertion Method:
  • 1. Start with a second number
  • 2. If the number is smaller than the previous one, swap to the previous position
  • 3. Repeat 2 until the number is not preceded by a number or the previous number is larger than

    1.5 What is the binary search method? It differs from the order lookup method?

    Binary Search method: First determine the midpoint position of the interval, compare the x value of unknown origin with A[mid], if equal, find the success and return to this position, if a[mid]>x, then the new search interval is a[1..mid-1] If a[mid]<x, then the new search interval is a[mid+ 1..N]
    The binary lookup method is applied to the sorted array, it is not necessary to compare each element, the speed is fast, and the sequential lookup method is used to repeat the group

    1.6 How are two-dimensional arrays defined and initialized?

    Definition: Type an array group name [President] [column length]
    Initialize: The initial value of the branch is assigned: int a [3] [3] ={{3}, {4,5,6}, {7,8,9}}, the order is assigned the initial value: int a [] [3] = {1,2,3,4,5,6,7,8,9}

    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.

    The elements on the diagonal are unchanged, the remaining elements are two subscript interchangeable
    Upper triangle: i<=j
    Lower triangle: i>=j
    Symmetric matrix: A[i][j]==a[j][i]

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

    Matrix, table

    2. This week's content, you are not what?

    For the part of the two-dimensional array is unfamiliar, some basic conceptual questions in the exam questions, as well as for handwritten code, the exam found that the knowledge of the function part is still not strong. For an array just know its basic concept, it involves the application level of the problem is cool. PTA in some need to judge the problem, not the first time to come up with the method of judgment sometimes forget to judge. Some of the topics are meant to be understood.

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.