C Language Blog Job--function

Source: Internet
Author: User
Tags arithmetic arithmetic operators logical operators

First, the PTA Laboratory work Topic 1: Use the function to determine the total square number 1. PTA Submission List:

2. Design Ideas
    • Issquare function

1. Define integer variable A,n;n control cycle times
2, A=0, when a is less than or equal to N, the execution loop 3
3, if POW (A, 2) = = N, return 1, otherwise continue to cycle, a++
4. Return 0

3. Problems encountered in debugging process and PTA Submission List situation description.

Partially correct: The return 0 is initially placed in the loop, resulting in the inability to validate the square of each number less than n, returning the result directly to 0. Misplaced: The return 0 is placed outside the loop.

Title Two: Use the function output in the specified range of the end number 1. PTA Submission List:

2. Design Ideas
    • Factorsum function

1. Define integer variable i,sum=0
2, if Numberd equals 1,sum=1
3, I=1, when I<number, perform 4, 5
4. If number%i==0,sum=sum+i
5, i++
6. Return sum

    • PRINTN function

1. Define Shaping variables I,j,k=0
2, I=m, when I<=n, execute 3.4
3, if Factorsum (i) ==i,k=1, output "i = 1"
4, j=2, when J

3. Problems encountered in debugging process and PTA Submission List situation description.

Partially correct: Follow the prompts

and debugging

1 can not be judged by the for (i=1;i<number;i++) loop, so add judgment, the answer is correct

Topic Three: Find the combination number 1. PTA Submission List:

2. Design Ideas
    • Main function:

1. define int type variable m,n;double type variable result
2. Input M.N
3, when m is less than or equal to N, result=fact (n)/(Fact (M) *fact (n-m)), output result, take the whole number of parts

    • The fact function:

1, define the integer variable i,double type variable a=1
2, I=1, when I is less than or equal to N, a=a*i,i++
3. Return a

3. Problems encountered in debugging process and PTA Submission List situation description.

Part of the correct: not very understanding of the PTA hint, part of the correct code, the results of the operation on C + + is right. After the students note that the topic said "title guarantee results in the range of double type" means that in addition to the result variable, a variable should also be double type, in order to ensure its value range, a type modified after the answer is correct. Pay more attention to the definition of variable type later!

Second, peer code pairs of peer review 1. Peer Reviews Photos

2. My Code, mutual evaluation of the student code

It's mine

Yu-Ying's

3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer?

The different points are mainly concentrated in the first function:

    • Difference point 1: Comment
      The classmate's code comment is clear, the readability is strong, in return to look at the code is easy to understand the thought

    • Difference point 2: Determine the number of digits
      Classmate's code first on the number of digits of the analysis, and I am through the analysis of the scope of the problem to determine the number of daffodils numbers of potential, if the number is too large to do this can be cumbersome, the student's practice is better

    • Difference point 3: the general idea
      I directly calculate the value of the number of people and then through the IF statement to determine whether the number is Narcissus number, and students are through the Do-while loop to calculate the value of each bit and accumulate the second side, and then through the IF statement to determine whether the number of daffodils. My code in the value range of the problem may be relatively simple, easy to understand, but it will be more cumbersome, step by step to seek the second side and. In the larger range of values, I think the practice of students is more desirable, students code scope of application is relatively wide. Some of the things I feel are not enough: the value of storing number I think one is enough, the variable is too easy to mess up, you can re-assign the B value to number after the first do-while.

Third, this week's topic set PTA Final ranking.

Iv. Summary of this week's study

1. What have you learned?

    • What data types are 1.1 C languages?

Integer, real, character, constructed type

    • 1.2 Character type data need to be aware of the place?

(1) Not only can be written in the form of character constants, can also be expressed in the corresponding ASSCII code, can be expressed in integers. Definitions and values for integer and char variables can be interchanged
(2) characters have numeric characteristics that can participate in operations like integers
(3) The escape character represents only one character
(4) All characters in the ASCII character set can be represented by escape characters
(5) The character needs to be enclosed in a ' ', there is no single quotation mark meaning different

    • 1.3 Self-increment decrement operator?

(1) ++n and n++ are equivalent to n=n+1
--n and n--are equal to n=n-1.

(2) As the value of an expression (emphasis!!!) )
The order of operations for ++n is to execute the n=n+1 first, and then the value of n as the value of the expression ++n
n++ The Order of operations is: first the value of n as the value of the expression n++, and then execute n=n++

    • 1.4 Operator Precedence?

(The priority order and the combination method of the 326 pages of the textbook are indicated in detail)
(1) Different priorities are calculated from highest to lowest priority, and if operators on both sides of the operands have the same precedence, the calculation order is determined by the combination direction
(2) operator precedence from highest to lowest: logical operators, arithmetic operators, relational operators, logical operators, conditional expressions, assignment operators, comma operators

    • 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, and comma expressions

1. Single topic score 10.0 Score: 0.0
The following program segment outputs the result of __.
int x=1, y=012;
printf ("%d", y*x++);

Correct: 10
my: 20
Cause: No serious reading of the book X + + and ++x The order of operations is different, at this time, the value of X.

2. Single-choice score 10.0 Score: 0.0
If a is of type int and its value is 3, then after the expression a+= a-= a*a is executed, the value of a is

Correct:-12
my:-3
Reason: In a+= this piece is unaware that the value of a has been changed from the right operation to 6 due to a calculation error

3. Single topic score 10.0 Score: 0.0
Set X, Y, T are all variables of type int, then EXECUTE statement: x=y=3; t= ++x | | ++y; , the value of Y is __.
Correct: 3
Error: 1
Reason: The topic is considered to be the value of T, because ++x is 1, so do not run | | After the ++y,y is still 3

1.6 Other content?

(1) Specify the output width of the integer data:%MD, if the actual number of bits is less than m, then the left fill space, if greater than M, the actual number of digits output (examination and review again)
(2) ch-' a ' + ' a ' converts lowercase characters to numbers
ch-' 0 ' convert numeric characters to numbers
val+ ' 0 ' converts numbers to numeric characters
(3) ' & ' | | ' The use of the ' ^ ' ~ ' operator
(4) Type conversion
1. Automatic type conversion
2. Forcing type conversions

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

This week the knowledge capacity is very large, especially for the symbolic operation of the knowledge points, for the priority of the symbol and like ' & ' | | ' ' ^ ' ~ ' operator is not very familiar with the operation, need to read the book. Encounter like the second and last question of the letter symbol type problem is stuck, usually for the letter symbol problem training is less, the use is not very good, there is like the fourth question for the binary conversion is not familiar with the problem, the law of the beginning of no idea, need to deepen the understanding of binary conversion.

3. Circular Structure Test Summary (all students must write)

1. What is wrong with the question, and how to change it?

Question fourth and fifth of the second question
The second question: because usually the letter question is less, the use is also not skilled, for the letter input output is more vague, and the examination time to the loop nesting relationship also did not fully understand, after the examination finishing thought again to hit again, discovered or can complete the simple question, the circulation is a control row number, a control input letter the number, Should be able to do it.
The fourth question: usually the conversion understanding of the binary system is also relatively vague, has not been done again, review the conversion to do a good job again.
The fifth question, encounter character letter question Heart is more afraid, see the question also has no train of thought, need to think again seriously ...

2. is the exam result satisfactory, how to improve?

Not satisfied. After the letter to the question to a lot of serious thinking about feelings, but also to be familiar with the conversion of the binary, for some such as character array this typical problem do not fear, well familiar with understanding, find out the relationship between the lines.

3. Other summaries.

For some of the necessary knowledge if it is vague to review in time, do not procrastinate on the existence of luck, like the binary and letter symbols, to master every knowledge point, otherwise it may be a terrible knowledge of the loopholes.

C Language Blog Job--function

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.