C language I work 04

problem answer
This work belongs courses C Programming Language II
Where the job requires https://edu.cnblogs.com/campus/zswxy/CST2019-4/homework/9772
My aim in this course is Learn C language knowledge, there are certain programming skills
In particular aspects of the job which helped me achieve goals In the body of the loop for loop, and arrangement conditions
references "C Programming Language"

1.PTA lab assignments

1.1. This problem requires programming, calculates the sequence 1 + 1/2 + 1/3 + ... and the first N.

1.1.1 Data processing

Data are expressed: the question has a variable i, N, sum, where N is an integer, and i, sum to floating point.
Data Processing: The title is used for the loop and the calculated sum + = 1.0 / i, the output required precision to 6 decimal places.

1.1.2 Screenshot experiment code

1.1.3 build test data

Input data Output Data Explanation
2 2.283333 Greater than 0
-1 Invalid Value! Less than 0

1.1.4.PTA submit a list and description


1. Compile Error: No marked with a semicolon at the end of the statement.
2. multiple errors: do not pay attention to the plastic float.
3. format error: not note the space requirements.

. 1.2 questions require programming, calculates sequence - front and N + 1/10 ... of Paragraph - 1/4 + 1/7.

1.2.1 Data processing

Data are expressed: The title using the variable i, n, sum, where i and n is an integer variable, sum of floating point variables.
Data Processing: The title used for the loop, calculated sum = sum + pow ((- 1), i + 1) * 1.0 / i, and requires accurate to three decimal places.

1.2.2 Screenshot experiment code

1.2.3. Create test data

Input data Output Data Explanation
1 1 Is greater than 0 and less than n
100 0.834 Is greater than 0 and less than n
-1 Invalid Value! Less than 0

1.2.4.PTA submit a list and description


1. A variety of errors: incorrect use of variable n, the printf written prinf.
2. Compile Error: The statement did not bring the end of a semicolon.
3. Wrong Answer: The formula input errors.

2. Code peer assessment



1. Before cycling I have been assigned to i, N, sum, he and I were in this place and I would not the same as he was before i only assignment.
2. I is calculated as sum + = 1.0 / i, where + = is the assignment operator addition, he calculated as sum = sum + 1.0 / i.
3. I accuracy of the output is specified as "% .6f", but he is only "% f".

summarize

In this study, we also learned a new syntax, for loop is, of course, more than that, I also learned some is that formula. I was on integer and floating point do not understand, because the last leave to miss a lesson, so I have no understanding for new things, working through this lesson and this time I have this knowledge, know "int", "float", "double" how to use, meaning there are "% d", "% f" of. But I still foggy on some topics, the face of some cases do not know where to start, hoping to learn more next time!

3.1. Learning progress bar

Week / Date This week the time spent Lines of code Learned knowledge Introduction Currently more confusing issues
4/16~4/22 2 hours Line 32 Basic code and the output starts, line breaks no
5/23~5/29 2 hours 20 lines Celsius Fahrenheit code the corresponding Not appropriate to use printf, the format can not grasp
6/7~6/13 6 hours Line 89 Seeking bank interest, written piecewise function, the output of the triangular area and perimeter I do not understand the function of the segment, where the use of if-else statements and scanf is not clear
7/14~7/18 6 hours Line 68 for loop statement summing the use of, the sequence. For some format and calculation methods also do not understand

3.2. Cumulative lines of code words and blog

3.3. Summarizes the learning content and insights

3.3.1. Learning content summary

The main contents of this study is that for loop, and it will be applied in the for loop statement must use a semicolon to separate the two conditions, should not be separated by commas. it must be for a single loop section of the loop body conditions and formulas not separated by a semicolon, because the segment is full.

3.3.2. Learning Experience

Learning C language, will find it hard, but sometimes you would think there are a lot of fun, such as the PTA do the job in the process, when he felt when entering a correct code, click submit is various errors, which I feel helpless, in fact, we can now compile their own download software go to try and grasp it when he can move inside to work. When faced with a problem it can not solve the query can also go online to look. In the learning process, there are do not know as much as possible themselves, so the harvest will be bigger.

Guess you like

Origin www.cnblogs.com/ssjjll/p/11695515.html