2019C fourth language jobs

This work belongs courses C Programming Language I
Where the job requires Job Link
My aim in this course is Mastery of the for statement
This job helped me achieve that goal in terms of specific PTA's statement for exercises and operations blog garden show
references Job Evaluation Criteria

1, PTA lab assignments

1.1 calculating partial sequence and the inverse of the square of

Problem Description: This problem requires two positive integers m and n (m≤n) programming, and calculates the sequence m 2 +. 1 / m + (. 1 + m) 2 +. 1 / (m +. 1) + ⋯ + n- 2 + 1 / n.

1.1.1 Data Processing

  • Data are expressed: the use of m, n, and Item SUM, represent m, n two variables, and the sequences and item i, the former two types are integer variables, the two double-precision floating-point variables.
  • Data processing: Use the double int variable defined, scanf input data, if-else branching to different data processing, calculations for loop statement, the last data output printf. Wherein the mathematical functions used to calculate the power function pow, expressed as item = pow (m, 2) + 1.0 / m and the sum = sum + item

    1.1.2 Screenshot experiment code

    1.1.3 build test data

    Input data Output Data Explanation
    1 10 387.928968 The sum of the first ten data - diagram
    5 10 355.845635 Sample title - diagram
    1 100 338355.187378 Data of the first one hundred and - run chart

    1.1.4 PTA submit a list and description

  • 1, a variety of error: the input digital data is no space between the two, not with 1.0 molecules, a plurality of statements less semicolon.
  • 2, wrong answer: do not pay attention to six decimal reserved.
  • 3, partially correct: not take into account the case where m = n.
  • 3, partially correct: taking into account the case of m = n, but for the first statement written expression m = 1, should be changed to m = m.

    1.2 seeking interleaving sequence and first N

    Problem Description: This requires programming problem, the sequence of staggered 1-2 / 3 + 3 / 5-4 / 7 + 5 / 9-6 / 11 + ... and the first N.

    1.2.1 Data Processing

  • Data are expressed: the denominator used denominator, N denotes the input data, flag custom variables used to represent each of the symbols, sum represents the sum value, item indicates item i, i denotes the number of cycles, numerator denominator.
  • Data processing: int using the same double define variables, scanf data input, calculations for loop statement, the last data output printf. There used expression:
    Item = Flag · numerator / denominator, SUM = SUM + Item,
    Flag-FLAG =, + 2 denominator = denominator,
    numerator numerator = + 1.0

    1.2.2 Code Screenshot

    1.2.3 build test data

    Input data Output Data Explanation
    0 0.000 Minimum Even - Graph
    1 1.000 Minimum odd - Graph
    8 0.377 Even - diagram
    11 0.904 Odd - diagram
    5 0.917 Sample title - diagram

    1.2.4 PTA submit a list and description

  • 1, a compilation error: numerator as the numerator, should be set to float to ensure that the item is a float variable.
  • 2. Compile Error: numerator word wrong.
  • 3, partially correct: flag before missing a negative sign.

    2, the code peer review

    Comparison of C language code for the third time jobs - the reference classmates - Picture Link
    Figure One classmate, Figure II is mine.

  • 1, variable definitions, input and output are the same, but I was carried out to a remainder operation, and then the remainder of the if-else x relational operation, the operator is used "and" (&&), so that the outcome; and the student is using the logical operators in the if-else statement directly "or" (||) relational operator to the initial data.
  • 2, agreed topics, consistent answers, the process is not the same, no matter which method has its advantages and disadvantages; I will carry out the remainder operation make the process more concise, but more joined a variable x, is more prone to error; the students did not join the new variables make the probability of occurrence of the error becomes smaller, more accurate title, but playing code more, spend some more time.
  • 3, apply their knowledge, to find a more simple and accurate method has always been my goal.

    3, learning summary

    3.1 learning progress bar

    date This week the time spent Lines of code Learned Introduction Currently more confusing issues
    10/14--10/20 8+ hours 190+ for use, if-else for used in combination with while the difference for

    3.2 Cumulative lines of code words and blog

3.3 Summary and perception of learning content

3.3.1 learning content summary

  • 1, for the statement: expression is determined by performing three cycles, and whether the next statement, the loop is too large to use {statement} bracketing.
  • 2, logical operators: && and || are other logical operators, precedence relationships with other operators to -! > Arithmetic Operators> relational operators> &&> ||> assignment operator.

    3.3.2 Learning Experience

    A: This week is relatively easy to learn, because there are before self-loop in advance, so for statements very easy to learn to use, to say the difficulties, I think the biggest difficulty is currently on the difference between while and for it, the two have in common is looping constructs are used, but I still have not figure out the difference. C linguistics it is not like the rumors as very dull, when you put into it, you probably only because the solution of a difficult problem, discovered a technique and happy for a long time, so would like a higher level, that sense of achievement It is the only personal experience to understand.

Guess you like

Origin www.cnblogs.com/solokill/p/11685201.html