# C Language Blog Job-data type

Source: Internet
Author: User

First, the PTA experimental work Title 1:7-3 inverted Digital string 1. PTA Submission List

2. Design Ideas

Define integer variable n holds the input number, I, J for Loop
Enter a numeric value n
For I=1
? The value of output I, i=i+1
? If n!=1, the output space
? When I>n, end loop
For j=n-1
? The value of the output J, j=j-1
? If j!=n-1, the output space
? When j<=0, end loop

3. Code

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

The first time to ignore the question of the space, the last number of output, it is followed by a space, and the title of the request does not meet

Topic 2:7-6 fall into the number of traps 1. PTA Submission List

2. Design Ideas

Defines an integer variable n holds the natural number of the input, N2 stores the newly generated natural number, sum=0 (sum holds each number together with and), Count=0 (count stores n the number of steps that fall into the trap), a holds the value of n
Enter the value of n
Do
? If count! =0, assign the value of N2 to n
? Assigns the value of N to a
? Do
?? To find the value of sum
?? N=n/10
? When n==0, end loop
? Number of steps count=count+1
? Find out the new natural number N2
? Outputs the values of Count and N2
? If the previous number A is not equal to N2, the output \ n
? Sum=0 preparing for the next cycle
When a==n2, end loop

3. Code

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

Just started to write the code, run the time to find the program into the dead loop out, not in the 4 when the end of the program, with Dev C debugging, found that their conditions with the wrong, where N should be changed to a, because the value of N in the front change, equals 0, so never equal to the value of N2

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

2. Design Ideas

Defines an integer variable n1,n2,result=0,flag=0 (flag=0 indicates that the division denominator is 0 or has an illegal operator), count=0
Defining the character variant op
Enter first operand N1 and first character op
When op!= ' = ',
? If count! The value of the =0,n is assigned to result, and another op is entered
Switch (OP)
? input N2
? According to the different OP, make the corresponding calculation, flag=1,count=count+1. If OP is '/' and N2 is 0 o'clock, flag=0
If op== ' = ' and count==0,
The value of RESULT=N1, flag=1
If Flag==1
Value of output result
Otherwise output error

3. Code

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

When the final result of the output error, resulting in a second figure, the case of the output error should be the existence of illegal characters and division when N2 is 0 o'clock, instead of N2 equals 0 output error

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? Defined

The general form of a one-dimensional array definition:
Type an array group name [array length];

``   int a[10]``
Initialization

1. When you define an array, you can assign an initial value to a group element

``   int a[10]={1,2,3,4,5,6,7,8,9,10};``

2. You can also target only some elements

``  int a[10]={1,2,3,}``

3. If you assign an initial value to all elements, you can omit the array length. If only partial elements are initialized, the array length cannot be omitted.

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, which is the first address. The array name is an address constant and is not allowed to modify

1.3 Why use arrays?

Allows the same type of variables to use the same array variable name, simple expression, readability, easy to use the loop structure
Using an array makes the program simple and avoids the hassle of defining multiple variables.

1.4 Introduction to the selection method, bubble method, direct insertion sort how to sort? Pseudo-code display. Selection Method:
• Defining integer Variables I,index,k,n,temp
• Define Array a[10]
• Enter the value of N and enter the number of n
• For i=0
• ? Assigns the number of inputs to the elements of array A in turn
• End Loop at I>n
• For k=0
• ? Small standard index=k with minimum value
• ? for I=k+1
• ? If a[i]<a[index],index=i;i=i+1
• ? When I>=n, End loop
• ? The minimum element is exchanged with the element labeled K, k=k+1
• When k>=n-1, end loop
• For i=0
• Output sorted Digital a[i],i=i+1
• When I>=n, end loop
Bubbling method:

-Define integer variable I,k
-Define Arrays

• Enter the value of N and enter the number of n
• For i=0
• ? Assigns the number of inputs to the elements of array A in turn
• End Loop at I>n
• For i=n-1
• ? for K=0
• ? If A[K]>A[K+1], exchange the value of two
• ? K=k+1
• ? When K>n, End loop
• I=i-1
• When i<0, end loop
• For i=0
• Output the sorted number A[i],
• ? i=i+1
• When I>=n, end loop
Direct Insertion Method:
• Enter n number
• For i=1,i<n,i++
• A[i] Compared to the previous number, if it is smaller than the previous number, continue to compare, until you find a smaller number than it, inserted after this number
• Repeat the above steps until I is greater than or equal to n

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

A set of data in order, first calculate its middle number, and the number to be looked up compared to the size, see in the middle number of the left or right, into the corresponding interval, repeat the above steps
Difference: When the data is long, the binary search method is efficient and the sequential lookup method is inefficient.
The binary lookup method requires the data to be ordered, and the order lookup rule does not have this requirement

1.6 How are two-dimensional arrays defined and initialized? Defined

Two-dimensional arrays are defined in the following form:
Type an array group name [line length] [column length]

`` int a [3] [2];``
Initialization

1. Assign all values

`` int a[3][3]={{1,2,3},{4,5,6},{7,8,9}};``

2. Partial Assignment

``  static int  b[4][3]={{1,2,3},{},{4,5};``

Equivalent to

``  static int b[4][3]={1,2,3,0,0,0,4,5};``
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.

A[I][J] In the subscript I, J Interchange into A[j][i] can be achieved transpose
Lower triangle: i>=j
Upper triangle: i<=j
Symmetric matrix: I==j

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

Primarily used to represent two-dimensional tables and matrices

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

How the array is defined is not very skilled, it defines the array when the array length is unknown.
For the various symbols of the priority has not been remembered, do the problem need to look at the book, especially the ^ symbol, will always forget the symbol is why
The ability to read the program is very poor, the examination of several questions wrong

C Language Blog Job-data type

Related Keywords:

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.