C Language Blog Job-data type

Source: Internet
Author: User
Tags array length

First, the PTA experimental work Title 1: Location Code Input Method 1. PTA Submission List

2. Design Ideas

Begin
1. Enter Zone_bit_code//int Zone_bit_code,high,low
2.high←zone_bit_code/100
3.low←zone_bit_code%100
4. Output character high+160
5. Output character low+160
End

3. Code

4. Problems encountered in debugging process and PTA Submission List situation description. Forget to change the location code entered into two bytes, resulting in an error.
correction : The location code is changed to two bytes using the method of taking redundancy, and 160 is added respectively, then output, the result is correct.
Topic 2: Inverted number string 1. PTA Submission List

2. Design Ideas

Begin
1. Enter n//int n,i,flag
2.for i←1 to N
1) Then if flag→1 output space
2) Output I
3) flag←1
3.for i←n-1 to 1
1) Then if flag→1 output space
2) flag←1
3) Output I
End

3. Code

4. Problems encountered in debugging process and PTA Submission List situation description. (1) Forget the output to space (2) after the addition of the grid, ignoring the title of the two digits between a space, but no space
correction : Use flag to control the output of the space

Topic 3: Simple Calculator 1. PTA Submission List

2. Design Ideas

Begin
1. Input N//n,i,sum,flag are integer variables, OP is character variable
2.sum←0
3.flag←0
4.sum←n
5.while op!= ' = '
1) Do input op
2) if op→ ' = ' Then break
3) Input I
4) sum←calculate (sum,op,i)
5) If op→ '/' and i→0 then flag←1
6) If op!= ' + ' and op!= '-' and op!= '/' and op!= ' thenflag←1
6.if flag→1
1) Then output "ERROR"
7.else
1) Output sum
8.calculate (A,OP,B)//define integer function calculate (int a,char op,int b)
1) If op→ ' + ' then sum←a+b//define integer variable Sum
2) ElseIf op→ '-' then sum←a-b
3) ElseIf op→ "
then Sum←a*b
4) ElseIf op→ '/' then if B!=0 then sum←a/b
5) Return Sum
End

3. Code


4. Problems encountered in debugging process and PTA Submission List situation description. 1. Problem understanding error, add the result to the previous calculation

correction : Sum=calculate (sum,op,i);
2. Do not consider the case of entering only one number
correction : The sum is processed when n is entered

Supplemental: Multiple repeat errors are for the purpose of viewing the error message.

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?
    • General form of definition: Type an array group name [array length]; Array length must be a constant
    • General form of initialization: Type an array group name [array length]={initial value table};
    • Note :
      1. If the static array is not initialized, the system automatically assigns 0 to all array elements
      2. Initialization of an array can only be for some elements
      3. Array initialization, if all elements are assigned the initial value, you can omit the array length, the system will automatically according to the number of initial values to the length of the group.
1.2 A one-dimensional array in-memory structure? can draw a description. What does an array name mean?
    • The array name represents the address of the first cell in the contiguous memory space allocated by the array
    • The array name is an address constant and is not allowed to be modified.
1.3 Why use arrays? An array is a set of data of the same type, with array names and subscripts that uniquely determine the elements of an array, and it is convenient to manage the data. 1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo code display.
    • Selection method:

For i←1 to n-1//n array length
Key←a[i]
K = i
For J←i+1 to N
If A[J] < key
K = J
Exchange A[i] and A[k]

    • Bubbling method:

For i = 1 to n//n array length
for j = N to I+1
If A[J] < a[j-1]
Exchane A[j] and a[j-1]

    • Insert Method:

For I←1 to N-1
For J←i-1 to 0
If a[i] > A[j] Break
If j!=i-1
Temp←a[i]
For K←i to J+2
A[K]←A[K-1]
A[j+1]←temp

1.5 What is the binary search method? It differs from the order lookup method?
    • Binary lookup: Suppose that the elements in the table are arranged in ascending order, comparing the keywords in the middle position of the table with the lookup keywords, and if they are equal, the lookup succeeds; otherwise, the table is divided into the front and the last two sub-tables with the intermediate positional records, and if the middle position record keyword is greater than the Find keyword, Otherwise, find the latter child table further. Repeat the process until you find a record that satisfies the criteria, make the lookup successful, or until the child table does not exist, the lookup is unsuccessful at this time.
    • And the difference between the order method: The two-point search must be from small to large arranged tables, two-point lookup method of finding fast, high efficiency;
      Sequential lookups are found from start to finish, compared to dichotomy, and are less efficient.
1.6 How are two-dimensional arrays defined and initialized?
    • Definition of a two-dimensional array: Type an array group name [length of line] [column];
    • Initialize: Type an array group name [line length] [column lengths]={{initial value table 0},...,{initial value table K}, ...} ;
      -The initialization of a two-D array can also be directed to only a subset of elements;
      -Sequential assignment of initial value: according to the order of the array elements in memory, the data in the initial value table is assigned to the element in sequence, if only some elements are assigned the initial value, attention should be paid to the order of the data in the initial value table;
      -When initializing a two-D array, if all elements are assigned an initial value, or if a branch is assigned an initial value, all rows are listed in the initial value table, and the line length can be omitted.
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: Defines the array a[i][j], then the array b[j][i] is the transpose matrix of the array a[i][j];
    • 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 arrays are used when a set of two-dimensional data is required, such as a matrix in mathematics. 2. This week's content, you are not what?
    • This week, the problem of PTA data type, the eighth question, the control condition is not very understanding, modified many times, or judgment are "yes", or are "no";
    • The nineth question has not yet been done;
    • The custom function of the array, as if to understand, but write not to write;
    • About midterm: Look at the code to find the wrong ability is a little weak, and the handwriting code is sure to strengthen.

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.