Which course does this assignment belong to | https://edu.cnblogs.com/campus/zswxy/SE2020-1 |
---|---|
Where are the requirements for this assignment | https://edu.cnblogs.com/campus/zswxy/SE2020-1/homework/11448 |
The goal of this assignment | Practice writing code , To deepen the If And so on |
Student number | 20209100 |
1.PTA Experiment assignment
1.1 Ask to read in 1 It's an integer X, Then the output 1+2+3+...X And .
1.1.1 Screenshot of experimental code
1.1.2 Data processing
Data expression : Using integer variables x,i,a,sum.i Is a cyclic variable ,x It's the end of the cycle .
Data processing : Use of the for loop , expression :i=1;i<=x;i++;sum=sum+i.
1.1.3 PTA Submit list and description
Q1: Floating point and integer are confused
A1: Read the title , Understanding functions
1.2 This question requires the preparation of procedures , Calculation sequence 1 - 1/4 + 1/7 - 1/10 + ... Before N Sum of items .
1.2.1 Screenshot of experimental code
1.2.2 Data processing
Data expression : Integer variables i,n,a,d Floating point variables b,sum, i Is a cyclic variable ,n It's the end of the cycle .
Data processing : Application for loop , expression :i=1,i<=n;i++, sum = sum + b.
1.2.3 PTA Submit list and description
Q1:scanf There is no... In the function &
A1: Just add it , Pay attention to
1.3 This question requires the preparation of procedures , Calculation sequence 2/1+3/2+5/3+8/5+... Before N Sum of items . Notice that the sequence starts from 2 Xiang Qi , The numerator of each term is the sum of the former and the denominator , The denominator is the numerator of the former .
1.3.1 Screenshot of experimental code
1.3.2 Data processing
Data expression : Using integer variables N, Floating point variables a,d,c
Data processing : Application for loop , expression :i = 0, i < N, i++, sum += d / a.
1.3.3 PTA Submit list and description
( I made it on my cell phone before )
Q1:printf in "%.2f" No decimal point .
A1: Just add it , Be careful in the future , It's better not to make such mistakes .
2. Reading the code
subject : Given an array of integers nums And a target value target, Please find and as the target value in the array Two Integers , And return their array subscripts .
1. The method is simple, but it runs slowly and consumes a lot of memory space ;
2. Use two for Sentence and a if sentence
3. got it malloc yes c Dynamic allocation of memory in language ,malloc Function returns void* type , So you have to cast the type to int
3. Learning summary
3.1 Learning progress bar
3.2 Accumulate lines of code and blog words
3.3 Learn to understand
After this period of study , I feel the professional content is becoming more and more complex , Homework is becoming more and more difficult , I feel inadequate in many ways , At the same time, I also found the importance of preciseness and patience in learning this major , Don't be impatient . I also found that there are some things that can only be experienced in person . It's hard to get anything if you don't do it . I'm glad I made a lot of mistakes in my homework , Although some have not been effectively solved , These will be solved after finishing this assignment .