C Language Blog Job--function

Source: Internet
Author: User
Tags arithmetic define function

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

1. Define function reverse (int number), type int
2. Define integer variable N,inverse=1;inverse to indicate reverse order number
3. Determine the positive or negative number, if number is less than 0, then n=-number; otherwise n=number
4.inverse=inverse*10+n%10
5.N=N/10;
6. Repeat step 4.5 until the n=0
7. Again determine the positive or negative number of a number, if number is less than 0, then return-inverse; otherwise return inverse
8. End algorithm

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

The initial code does not take into account the question of positive or negative, so after the submission prompted that the negative and 0 are not considered, and then after the following look, submit or display part of the correct

It is found that the condition of the called while Loop statement is wrong, and the error is not output until the condition is not met.

Topic 2: Daffodils number 1. PTA Submission List

2. Design Ideas

Call function narcissistic (int number)
1. Define integer variable int i,x,h,y,count,sum;
2.sum=0;count=0;x=number;y=number;
3. Determine the number of digits, x=x/10,count++, until x=0
4.h=y%10,sum=sum+h,y=y/10
5. Determine whether the sum of the n-th of the decomposition is equal to number, that is, repeat step four
6. If Sum=number,return 1; otherwise return 0
Call function void Printn (int m, int n)
1. Defining integer Variables J
2. If narcissistic (j) = 1, Output m
3. Repeat step 2;
4. End algorithm

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

At the beginning, the PRINTN function misspelled, resulting in a compilation error.

Later in the group asked the classmate after change, but still output error

After debugging, it is found that Y will change at output, and it will change with the value of y=y%10.

Later found that the original missing Y/10 after the middle value, and then define an integer variable h,h=y%10; you can solve

Topic 3: Finding the number of combinations 1. PTA Submission List

2. Design Ideas

1. Define two integer variable m,n; define floating-point variable result
2. Enter M,n
3. Invoke fact (int n) to find factorial
4.result=fact (n)/(Fact (M) *fact (N-M))
5. Output result

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

Start without a good understanding of the meaning of the calling function, write the initial code as follows


Start thinking too complex, do not consider the meaning of the function, has been lost, and then carefully read the textbook about the function of the chapter, and in the classmate's explanation to understand the definition of function, and then changed to this


Answer output 0, there is no definition of the function parameter n, the type should be int, and the output of the time to forget the explanation is output result, blame yourself too careless, make this low-level error

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

2. My Code, mutual evaluation of the student code


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.

The biggest difference between me and the violin code is to judge the positive and negative nature of N, I use the assignment, and then put their situation together to discuss, and the practice of the piano is to separate them to discuss, I think this is too cumbersome to write;
Each of the advantages, relatively speaking, my code is relatively concise, and the Code of the piano is comparatively easy to understand, the readability should be higher, I always forget to write comments when writing code, and the code of the piano even more complex than me, but his code has a lot of comments, so that people can easily understand.

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

Iv. What data types does the 1.1 C language study summarize this week?

There are three types of data in the C language, namely integer, character, real

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

Character type and character constants:
Each character type data occupies one byte in memory, which is used to store its assii code;
Both the definition and the value of the integer variable and the character type variable can be exchanged with each other;
When exchanging the definitions and values of integer and character variables, the range of integer data is a valid ASSII code;
A character constant refers to a single character, expressed as a pair of single quotation marks and their enclosed characters;
' A ' and ' a ' are different character constants, ' 0 ' and 0 are constants of different types, the former is a character constant, and the latter is an integer variable;
The escape character consists of a backslash plus a character or number

1.3 Self-increment decrement operator?

The self-increment operator + + and the decrement operator--have the following two functions:
(1) Increase the number of variables by 1 or minus 1; if n is an integer variable and has been assigned, then ++n and n++ are equivalent to N=n+1;--n and n--equivalent to n=n-1;
(2) Take the value of the variable as the value of the expression; for example: the value of the expression ++n and n++ is evaluated, then the order of operation of the ++n is: n=n+1 is executed first, then the value of n as the value of the expression ++n;
Operands of the increment and decrement operators can only be variables, not constants or expressions

1.4 Operator Precedence?

In arithmetic, following the "first plus minus multiplication" operation rules, the precedence of operators in C is also calculated from high to low; if the operands are of the same precedence, then the order of calculation is determined by the binding (binding direction), and if the binding direction is "left to right", the operator with the operand is preceded to the left. If the union direction is right-to-left, the operand is preceded by the operator

1.5 which expressions are in C language? What do you do wrong in class, please analyze the reason here?

1. An arithmetic expression, an assignment expression, a relational expression, a logical expression, a conditional expression, a comma expression.
2 · Class School data
Expression type and expression
(1) The second problem, X + + operation order is the first to the value of the expression, and then execute the x.
(2) The 8>6>3; operator has the same priority, starting from left to right, 8>3 is true, 1,1>3 is false,
(3) The value of the expression (j=3,j++), J + + in the order of operation is the first to put the value of the expression as a, and then execute J + +, the result is 3

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

This week, the use of functions is not very flexible, for some simple topics can write code, but more complex function calls do not know how to implement the function, and the data expression type is not very understanding, for binary, octal, decimal and hexadecimal arithmetic principles do not understand

3. Circular Structure Test Summary (all students have to write) 1. What is wrong and how to change it?

This week on the machine test almost all the questions have done wrong, accurate, should be read the first question, after the first problem stuck, there is no thought to see; The following is the first three questions after the end of the exam, the last two questions have not been understood
7.1
7.2
7.4

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

The results of the exam is very dissatisfied with the exam, completely forget the basic knowledge, even the simplest of the questions are not done, the basic knowledge of the very bad, may also be the usual time to think about the problem is not enough, too dependent on classmates, after serious thinking about each problem, encountered problems of their own independent thinking, Put more time and energy into C language learning.

3. Other summaries.

This time on the machine test is very poor, the analysis of the problem is not in place, there are problems encountered, will not find their own mistakes, may be the basis of knowledge and not mastered, resulting in a lot of problems will not solve their own, and their own time is not scientific, it seems that there is a lot of time spent on learning, But in fact, not much use, let oneself live very tired every day, but the study still did not learn, so plan your own time, do your own thing.

C Language Blog Job--function

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.