C language Ⅰ blog work 04

This work belongs courses C Programming Language Ⅰ
Where the job requires https://www.cnblogs.com/tongyingjun/p/11695948.html
My aim in this course is Master for loop and three expressions statement, statement of preliminary understanding pow usage
In particular aspects of the job which helped me achieve goals PTA five jobs, and the compiler may write their own code and code errors
references C Programming Language, literature Baidu

1.PTA lab assignments

1.1 in Simple sequence before interleaving N items and
present questions require programming, calculates sequence - 1/4 + 1/7 - 1/10 ... of the first N + sum. In a given input row positive integer N. Output format: output section and in accordance with the value of S "sum = S" format in a row, accurate to three decimal places. Title ensure that the calculation result does not exceed the double precision.
⑴ data processing
① expression data: int This problem with the plastic structure, the variables and inf sum, sum is the dependent variable, varies with changes in n.
② Data processing: Use the for loop structure and if-else statements, the second circulation inside the braces is the content, wherein the selective structure.
⑵ experiment code shots

⑶ create test data

Input data Output Data Explanation
2 0.750 >1
10 0.819 >9
100 0.834 >99
101 0.837 >100

⑷PTA submit list describes the

cause of the error
Q1 compile error: in their own compiler compiler above sum no matter what the input is zero, I think that this problem so the compiler has to pay on the PTA interview, the result is wrong.
A1: find yourself behind the sum entered in the code above is wrong, the output becomes 0 S.
Q2 compile error: Compiler face on their copy above PTA will have a compilation error.
A2: ask the assistant, the result is I forget to copy the leading #.

1.2 seeking interleaving sequence and first N

Questions require programming, the sequence of staggered 1-2 / 3 + 3 / 5-4 / 7 + 5 / 9-6 / 11 + ... and the sum of the first N. Input format: In the given input row a positive integer N. Output format: output section and a value in a row, the results of three decimal places.
⑴ data processing
① Expression Data: The title structure was used int plastic, variable in. There are double precision floating point, due to the variable sum varies with changes in n.
② Data Processing: The title used for the loop structure, the second content inside the braces are circular, scanf format control characters are used to input data. Meanwhile POW () is math, h for calculating the power of x to y, the title is a molecule.
⑵ experiment code screenshots

⑶ create test data

Input data Output Data Explanation
5 0.917 >1
11 0.904 >10
100 0.391 >99
101 0.894 >100

⑷PTA submit a list of instructions

Cause of error
Q1 compile error: Compiler Error in place of the above their math.h not entered in the second line
A1: In the Baidu search above came to realize after the
Q2 compilation error: Do not know the for loop structure in this application pow structure so wrong a few times.
A2: own in the book above information checked Baidu also saw above came to understand a little bit.
Q3 compilation errors: in front of the double-precision floating-point application, inside the back printf% lf mistyped.
A3: valiant think of it written in the book above.

2. Code peer assessment

⑴ students Code shots (three shifts from the software has good students)

own codes shots (7.3)

⑵ comparison
the same point: the use of plastic int and double and double precision floating point, there is a structure of pow
differences: ① different variables used
② loop structure inside the contents of different
two compared, had good students is relatively simple, he's the number of lines of code than I, more complicated. My relatively simple.

summarize

⑴ learning progress bar

Week / Date This week the time spent Lines of code Learned knowledge Introduction Currently more confusing issues
the fourth week Four hours 85 I learned a for loop in Baidu above a preliminary understanding of the usage of pow pow usage as well as cyclic structure

⑵ cumulative number of lines of code and blog

3.3 Summary and perception of learning content

⑴ learning content summary
① learned this lesson on how to use the looping structure for statements, know for a general expression for the statement to use two semicolons to separate the three expressions, in the middle there is a call for statement cycle control variables.
② know the meaning of the statement in the middle of three expressions for and how to use.
③ own C language is not very understanding but also to learn a lot of knowledge, learning only book the above is not enough, you also need to own additional study.
④ while knocking in the middle of the code works with those who remember their place was wrong and remind yourself not to make the same mistake next time.
⑵ learning experience
① with expertise in learning to understand things more and more.
② knowledge to know how much your code is also more, know more than the previous error code when a little faster to find the wrong place.
③ themselves in knocking the code when the speed is also fast, but some common mistakes still occur, it is not careful, looking for the wrong time should be careful.
④ the profession to own a lot to learn outside school hours, we also have to knock a bit of code, the only way to improve yourself.

Guess you like

Origin www.cnblogs.com/tongyingjun/p/11695948.html