C Language Blog Job-data type

Source: Internet
Author: User

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

2. Design Ideas

Define integer variable a store input location code define integer variable b,c store code
Enter the location code and store it in a
c=a%10+ (a/10%10)10;//Remove each digit of a and deposit in B,c
b=a/100%10+ (a/1000%10)
10;
Putchar (160+b);//Output
Putchar (160+C);

3. Code

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


The main problem encountered is not read clear test instructions Location Code no one input leads to an answer error

Topic 2:7-3 inverted digit string 1. PTA Submission List

2. Design Ideas

int n,i=1; n is used to store the range, I is the number of loops
Input n
while (i<n) {//When I is less than n then output i
printf ("%d", I);
i++;}
I=n
When I is greater than 0 o'clock output I
Remove spaces when I=1

3. Code

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


Format error due to I=1 without whitespace

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

2. Design Ideas

The int n,m,result=0;//n,m is used to store the number of results to be calculated to store the result of the operation
Char ch;//used to store operators
Executes a loop to calculate the input equals sign when the loop ends
if (ch== '/' &&m==0| | ch!= ' + ' &&ch!= '-' &&ch!= ' * ' &&ch!= '/') {//If the division denominator is 0 or has an illegal operator, the output error message "Error"
Judging operators and calculating them
n=result;//n= Result after completion of operation
Output results

3. Code

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



The main problem encountered in this case is that the operand is not n=result to store the result after one operation, and is solved by debugging.

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?

Defines and initializes an array of integers such as int a[2]={1,2};

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

The storage structure in memory is linear and the array name in order is the address of the first element.

1.3 Why use arrays?

Saving memory, and using arrays 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

(1) Sorting by selection method
1. Defining Integer Variables I,min,k,n,temp
2. Define Array a[10]
3. Enter integer n
4. Make i=0
5. When i<n, enter the number, i++
6. Save the number of inputs to the N elements of array a sequentially
7. When k=0;k<n-1, use min to store minimum value
8. Determining the size of elements and a[min] in array a
9. If a[i]<a[min],min=i, the minimum element is exchanged with the element with the subscript K
10.temp=a[min];
11.A[MIN]=A[K];
12.a[k]=temp;
13. Output sorted by number
(2) Bubble method sequencing
1. Define Array A[n]
2. Defining integer Variables I,j,temp,n
3. Make i=0
4. When I meet <=n-1
5. Number of inputs a[n]
6. Make i++
7. Assign this set of data to A[n]
8. Determine the two adjacent data, if A[J]>A[J+1], to Exchange
9.TEMP=A[J]
10.A[J]=A[J+1]
11.a[j+1]=temp
12. Q-i the step, which can be sorted
(3) Ordering by direct insertion
1. Define Array A[n]
2. Defining integer Variables I,j,k,min
3.i=0;
4. When I<=n-1 is satisfied
5. Enter Number A[n].
6.i=0;
7.min = minimum Value
8. Determine the size of the data a[j] and min
9. If Min<a[j],a[j]=min
10. Move the data gradually through A[K+1]=A[K]
11. Repeat n-1 times to sort

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

For an ordered array of length n, the idea of dichotomy is gradually split into a very fractional group to find solutions.
I think the sequential lookup method is relatively inefficient and the dichotomy is quicker to find.

1.6 How are two-dimensional arrays defined and initialized?

Define arrays of data types directly as one-dimensional arrays
(1) You can assign a value directly to the class when you define it.
(2) You can assign a value to an element after it is defined
For example int a[2][2]= {{1, 2}, {5, 6}};

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.

Defines two arrays used to store the pre-transpose and transpose matrix respectively, the two arrays of row subscript and column subscript interchange can be achieved transpose
Lower triangular i<=j Upper triangular i>=j

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

Primarily used to describe table structures or to represent matrices and matrices

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

For the bubble sorting method, select Sort, insert sort also mastered not very skilled, for the binary search is not too clear.

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.