First, the PTA Laboratory work Topic 1: Use the function to output an integer in reverse order number 1. PTA Submission List
2. Design Ideas
- First step: Call the Math function
- Step two: function definition int reverse (int number)
- Step three: Define the integer variable count=0,i,remainder (remainder), inversion=0 (number of reverse order), a (the value of storing the numbers)
- Fourth Step: A=number
- Fifth Step: Number=number/10,count=count+1
- Sixth step: When number does not wait for 0 o'clock, repeat step 5, when Numberde equals 0 o'clock, end loop, go to next step
- Seventh Step: REMAINDER=A%10,A=A/10
- Eighth Step: Count=count-1,inversioon=inversion+remainder*pow (10,count)
Nineth step: When a does not wait for 0 o'clock, repeat steps 7, 8, when a equals 0 o'clock, end the loop, go to the next step
Tenth step: Return the value of inversion to the main function
3. Problems encountered in commissioning process and PTA submission List status noteAt the beginning of the output, a number of more than one, after debugging, found that their count is misplaced the count should be placed in front of the line
Topic 2: Use a function to output the number of Fibonacci within a specified range of 1. PTA Submission List
2. Design Ideas
- First step: function definition int fib (int n)
- Step two: Define the integer variable I,number,a=1,b=1,c
- Step three: I=3,i is less than or equal to n
- Fourth Step: C=a+b,number=c
- Fifth Step: A=b,b=c
- Sixth step: Repeat steps 4, 5, until I>n
- Seventh step: If N==1 or n==2,number=1
- Eighth step: Return the value of number to the main function
- Nineth step: function definition void printfn (int m,int N)
- Tenth step: Define an Integer variable k=1,count=0
- 11th Step: When Fib (k) <=n, go to the next step
- 12th step: If Fib (k) >=m and fib (k) <=n, when count is not equal to 0 o'clock, the output space
- 13th Step: Output fib (k) value, count=count+1
- 14th Step: k=k+1
- 15th step: Repeat step 12-14, when fib (k) >n, end loop
16th step: If count==0, output no Fibonacci number
3. Problems encountered in commissioning process and PTA submission List status noteWhen the code that was originally written outputs all the Fibonacci in a given range [M, n], it runs slowly when the value of M, N is large, and when it is submitted, the display runs out of time
Later on the Internet query, understand the other people's writing, and think about it, changed the code after the
Topic 3: Finding the number of combinations 1. PTA Submission List
2. Design Ideas
- First step: function declaration double Fact (int n)
- Second step: main function: Define floating-point variable result, define integer variable m, n
- Step three: Enter values for M, n
- Fourth Step: Result=fact (N)/(Fact (M) *fact (N-M))
- Fifth step: Output the value of result
- Sixth step: function declaration double Fact (int n)
- Seventh step: Define integer variable i, define floating-point variable item=1
- Eighth Step: I=1,i<=n
- Nineth Step: item=item*i,i=i+1
- Tenth step: Repeat step 9, when i>n, end loop
- 11th Step: Return the value of item to the main function
3. Problems encountered in commissioning process and PTA submission List status note
1. function declaration when the double fact (int n) is just beginning to write int fact (int n), and then there is a test point, I can not find the mistake, ask the classmate's help, the classmate helped me to find the mistake
2.item was first defined as an integer variable, debugging results are not correct, and I looked at the code again, changed to come over
Second, peer code pairs of peer review 1. Peer reviews Photos.
2. My Code, mutual evaluation of the student code
My Code
Liang Caiyu The code of the classmate
3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer? If the classmate code is wrong, please help to point out where the problem.
My code is concise, the execution is high efficiency, and the classmate's code is long, the execution efficiency is low, she uses the circulation method, when the numerical value is big, must execute many times to judge the result, compares not to be practical
I prefer my own code.
Third, this week's topic set PTA Final Ranking
Iv. Study Summary of the Week 1. What did you learn? What data types are 1.1 C languages?
Integer, character, and real. The real type is also divided into single-precision float and double doubles
1.2 Character type data need to be aware of the place?
' A ' and ' a ' are different types of character constants
The character constants can be represented by the corresponding ASCII code, or they can be represented by integers.
1.3 Self-increment decrement operator?
++n, executes the n=n+1 first, and then the value of n as the value of the expression ++n
n++, the value of n is first used as the value of the expression n++, and then n=n+1 (-N, N-and ++n, n++) are executed.
1.4 Operator Precedence?
In order from high to Low: logical operator (! ), arithmetic operators, relational operators, logical operators (&&, | | ), conditional expressions, assignment operators, comma operators
Monocular operator > Binocular operator
1.5 which expressions are in C language? What do you do wrong in class, please analyze the reason here?
arithmetic expressions, assignment expressions, relationship expressions, logical expressions, conditional expressions, comma expressions
9th small question (j=3,j++)
The correct answer is 3, and I chose 4, for J + + understanding is not thorough enough, should be the value of J + + as the value of J + +, and then perform j=j+1 this step, so (j=3,j++) the value is 3, and J is the value of 4
1.6 Other content?
The input format control for double type data must be%LF or%le
The type of the expression on the right side of the assignment number is automatically converted to the type of the left variable of the assignment number, and the type of the right expression of the assignment number is higher than the type level of the left variable of the assignment number and the precision of the operation is reduced
2. This week's content, you are not what?
For the last question on the machine test that character type of topic, I still do not know very well, see the topic a little bit of the feeling, may be for this type of problem I need more practice
3. Circular Structure Test Summary (all students have to write) 1. What is wrong and how to change it?
is less than the maximum number of 10 primes, accidentally enclosed in the wrong place, resulting in the judgment of the prime, what can not be lost, they did not find errors, and then after the teacher to know that they are wrong in the position of the brackets wrong
2. is the exam result satisfactory, how to improve?
is not satisfied, the prime number that the question usually has done several times to judge the prime number, but the examination due to own not earnest, causes oneself in this question spends too much time, the latter two questions have no time to do again
The next time you will be serious, have not met, to change their strategy, first to do other topics, not on the bar
3. Other summaries
Experience is constantly accumulating, for oneself do not good place, must have a good reflection, strive to not make the same mistake again next time. For their own do not understand the place, must be diligent to turn over the book, ask students and teachers, so as to continue to progress. Learning is boring, but I hope I can hold on
C Language Blog Job--function