C Language Blog Job--function

Source: Internet
Author: User

First, the PTA experimental work 1. Symbolic function 1. PTA Submission List

2. Design Ideas
    • (1) Define result to indicate results
    • (2) If x>0,result=1
    • (3) If x<0,result=-1
    • (4) Otherwise, result=0
    • (5) Return results

      3. Problems encountered during commissioning and solutions

      The problem is solved by branching structure.

Topic 2. Use function to output Narcissus number 1. PTA Submission List

2. Design Ideas
    • (1) Defining integer variables I, j, Digit, Power, Powersum, Integer, count=0
    • (2) Integer = number
    • (3) using the while loop, if integer > 0,integer = INTEGER/10, count the number of numbers, count the number of digits
    • (4) Integer = number
    • (5) using a For loop, i = 0; I < count; i++,digit = integer% 10,integer = integer/10,j = 0; J < Count; J++,power = power*digit,powersum=powersum + Power
    • (6) If powersum==number, return 1, otherwise return 2
    • (7) Define sub-function void printn (int m, int n)
    • (8) Definition I
    • (9) Use the For loop to accumulate I until m+1=n
    • (10) If narcissistic (i) =1 output I

      3. Problems encountered during commissioning and solutions

      I didn't pay attention at first. To redefine the initial value of the powersum, resulting in the result has not been lost

      Topic 3. Number of combinations 1. PTA Submission List

2. Design Ideas
    • (1) Definition I,n,m,x,y,z
    • (2) input m,n,x=fact (n), Y=fact (M), Z=fact (N-M)
    • (3) Define a child function double fact (int n)
    • (4) Define integer variable i, floating-point variable result=1
    • (5) using a For loop, i=1;i<=n;i++,result*=i
    • (6) Return result
    • (7) Output result

      3. Problems encountered during commissioning and solutions

      Do not know why has been deducted two points, do not know why M=N/2 when the answer is wrong, in the DEC test is not wrong

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

2. My Code, mutual evaluation of the student code
    • My Code

    • Liu Bohan's Code

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

Bo Han's code with the POW function to solve, and I do not, I feel my code is more concise, looks more comfortable, but our code is not annotated, need to improve later

Third, this week's topic set PTA Final Ranking

Iv. Learning Summary 1. What have you learned? What data types are 1.1 C languages?
    • Integer floating-point character type

      1.2 Character type data need to be aware of the place?
    • Use%c,getchar () to add single quotes when entering

      1.3 Self-increment decrement operator?
    • n++ represents the value of N plus 1, but n++ equals the original n,++n represents the value of N plus 1, but n++ equals the current n

      1.4 Operator Precedence?
    • superior to low elementary operator single-mesh operator arithmetic operator shift operator relational operator bitwise logical operator logical operator three-mesh operator assignment operator comma operator

      2. This week's content, you are not what?
    • (1) will not be a lot of places, the function of a little more complex point of no idea, to go online to see other people's code ideas to play out
    • (2) The self-increment decrement operator is not very clear, the expression is easily mistaken
    • (3) Operator Precedence cannot be remembered, and it is easy to be mistaken during operation

      3. Circular Structure Examination Summary

      The exam is very poor, the first exam can pass, this time by the second problem card half-dead, feeling now learning more difficult, a little rare to keep up with the teacher's progress, from the cycle structure began a bit will not, my own learning attitude also a bit of a problem, I learned that the professional university there is nothing to play, honestly dozen code it, After these two examinations, the heart is still relatively lost, hoping to slowly adjust to come, will not understand, and strive to keep up with the footsteps of teachers and classmates.

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.