当前位置:网站首页>C language I blog assignment 03

C language I blog assignment 03

2020-11-06 21:13:21 itread01

| This assignment belongs to that course |https://edu.cnblogs.com/campus/zswxy/SE2020-3 | | ---- | ---- | ---- | | Where are the requirements for this assignment |https://edu.cnblogs.com/campus/zswxy/SE2020-3/homework/11450 | | The goal of this assignment is | Explore problems in learning , Sum up your own gains , Improve existing problems | | Student number |20209167 | ###1.PTA Experimental assignments #### From PTA Choose from the topic set 3 You are most satisfied with the topic, complete the following content , The more difficult it is to choose a topic , Higher score , Every question 2 branch , The content requirements are as follows : 1. This question requires programming , 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 . Input format : Input gives a positive integer on a line N. Output format : Output the value of the partial sum in one line , Accurate to two decimal places . The title guarantees that the calculation result does not exceed the double precision range . 1.1.1: ![](https://img2020.cnblogs.com/blog/2180242/202011/2180242-20201105193145945-1796529269.png) 1.1.2: ``` Data expression :i,N Is an integral function ,q For substitution variables ( Floating point variables ),sum,fz,fm,s Is a floating-point variable Data processing : among s Denotes each term of the formula ,fz,fm The numerator and denominator ,sum It's the end result ,q It's a variable in the loop , Adjust the final output to two decimal places according to the requirements of the topic . ``` 1.1.3: ![](https://img2020.cnblogs.com/blog/2180242/202011/2180242-20201105213533331-123897089.png) * Q1: It didn't work at first q Substitution variable , It leads to calculation errors , Partially correct . * A1: It was used q Replace , The calculation procedure is correct , Problem is solved . 2. There's a self proclaimed microblog “ Big Ben V” The guy of , The bell is rung every day to urge farmers to take good care of their bodies and go to bed early . However, because of the stupid clock's own work and rest is not very regular , So the bell doesn't ring at the right time . Generally, the number of points to be struck is determined according to the time of ringing , If it happens to be at a certain hour , So “ When ” The number is equal to that whole number ; If it's past the hour , Just hit the next whole number . in addition , Although one day there is 24 Hours , The clock only strikes in the second half of the day 1~12 Next . For example, in 23:00 Ring the bell , Namely “ Dangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdang ”, And by the 23:01 It will be “ Dangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdangdang ”. In the middle of the night 00:00 Until noon 12:00 Period ( Endpoint time is included ), Stupid clocks don't strike . Now please write a program , Ring Big Ben according to the current time . Input format : Enter the first line according to hh:mm The current time is given in the format of . among hh It's an hour , stay 00 To 23 Between ;mm It's minutes , stay 00 To 59 Between . Output format : Ring Big Ben according to the current time , That is, output the corresponding number of Dang. If it wasn't for the bell , Then output : Only hh:mm. Too early to Dang. among hh:mm It's the input time . Input sample 1: 19:05 Output sample 1: DangDangDangDangDangDangDangDang Input sample 2: 07:05 Output sample 2: Only 07:05. Too early to Dang. 2.1.1: ![](https://img2020.cnblogs.com/blog/2180242/202011/2180242-20201106173007068-1964507269.png) 2.1.2: ``` Data expression : Define time hh,mm( Integer data ),i,n It's also integer data . Data processing : Yes for Sentence ,ceil Function calculation does not exceed mm The smallest integer of n=hh-12+ceil(1.0*mm/60);, use if Set the time period for the topic . ``` 2.1.3:![](https://img2020.cnblogs.com/blog/2180242/202011/2180242-20201106174614153-861468868.png) * Q1: At the beginning if The sentence is typed in brackets = So compilation errors . * A2: Change to == That's right . * Q2: There are input and output format, no attention to the space . * A1: The format is correct after correction . 3.L1-031 Is it too fat (10 branch ) It is said that a person's standard weight should be his height ( Unit : Centimeter ) Subtract 100、 Multiplied by 0.9 The number of kilograms you get . The error between the real weight and the standard weight is 10% Inside are perfect bodies ( namely | Real weight − Standard weight | < Standard weight ×10%). It is known that the market weight is twice the kilogram . Given the height and actual weight of a group of people , Please tell them if they are too fat or too thin . Input format : Enter the first line to give a positive integer N(≤ 20). And then N That's ok , Each line gives two integers , It's the height of a person H(120 < H < 200; Unit : Centimeter ) And real weight W(50 < W ≤ 300; Unit : Jin ), They are separated by spaces . Output format : Output a line of conclusions for everyone : If it's the perfect body , Output You are wan mei!; If it's too fat , Output You are tai pang le!; Otherwise output You are tai shou le!. Input sample : 3 169 136 150 81 178 155 Output sample : You are wan mei! You are tai shou le! You are tai pang le! 3.1.1: ![](https://img2020.cnblogs.com/blog/2180242/202011/2180242-20201106195908334-21870128.png) 3.1.2: ``` Data expression : among i,n For integer data ,W For floating point data . Data processing : According to the requirements of the subject data, give the definition variable , According to the formula if Statement processing , Output the given decision statement . Yes fabs Function to calculate absolute value, etc .( Standard weight ) W=(h-100)*0.9*2,f

版权声明
本文为[itread01]所创,转载请带上原文链接,感谢