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
3. Code
4. Problems encountered in debugging process and PTA Submission List situation description.
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.
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?
C Language Blog Job-data type