I. First question 7-1
1. PTA Submission
2 Design Ideas
The subject requires the use of sub-functions to calculate the number of combinations, note that the subject variable requirements are double floating-point type, in the main function of the input range M,n, the sub-function is to find the factorial of sum, and in the sub-function with the combined number formula can be
3 Code
Topic 2 7-10
1 PTA Submission
2 Design Ideas
The subject asks for a different year of n numbers encountered, defines num[4]={0},n[10]={0}, and has a years=year that stores each number of years with NUM, then uses n[num[i]]++ in the I loop, when n is not equal to 0 o'clock, k++, Loop End exit Judgment K=dif, jump out of cycle, if not, then n is re-assigned 0, and will enter the next year,k=0, the final output should be the value.
3 Subject Code
4 problems encountered
Before the idea of the code is completely different from this, I was to execute the count++ by judging each digit of the year, the result later found that too much detail, and then always modified, modified to the last or not all right, so changed the idea.
3 7-5
1 PTA Submission
2 Design Ideas
In this paper, we ask for the approximate pi, and give the formula, the main problem is the use of sub-function, the numerator is factorial, the denominator is 3*5*7, the circulation can be several times.
3 Subject Code
Two this week's PTA rankings
Three classmates code Mutual evaluation
1 Peer Reviews
She Yehui
2 My Code, peer-to-peer code
3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer? If the classmate code is wrong, please help to point out where the problem
Differences: I use a double to define the sub-function, and the classmate with a void, no return value, I think there is a return value looks clearer, there is the definition of pi students used static variables, time, and I have to re-enter each time the more trouble, I prefer the students to the details of the treatment, Like their own ideas.
Iv. Summary of this week's study
1. Child functions can make the code look more convenient when used with child functions.
2. We have also learned the use of pointer arrays, but I do not have much to show here, mainly due to the unfamiliar use of pointers arrays, pointers are not familiar with the address.
One PTA Laboratory work
1.7-21
2. Design Ideas
The main requirement is to shift the policy to the right, mainly the last number and the first number of docking. I first save the last number with a number and then put the last one in the first repeating loop n times when the other loops end.
3 Code
4 problems encountered in the subject
At that time careless in the output of the time to write J + + i++.
Second question 7-5
1 PTA Submission
2 Design Ideas
The main problem is to sort the length of the string, the basic idea is not difficult, but in the input and sorting need to use new things, such as strcmp compare the input character is #, there is strlen compare the length of the character, strcpy the string swap, and the first function of the definition, Remember to add a string.
3 Code
4 Problems encountered during debugging
The first input loop here, forget to i++, become sum++, cause the answer is wrong
Third question 7-14
1 PTA Submission
2 Design Ideas
The main point is to insert a number in a series of numbers, so I define two arrays, so that the second array is larger than the first one, first they are all equal, and then find the insertion position, insert it
3 Code
4 Problems encountered during debugging
I don't know why I can't get a perfect score, and each time I submit it is different.
Second, the PTA final ranking of this week's goal set.
Third, the student Code mutual evaluation
1 Peer Reviews
She Yehui
2 My Code, peer-to-peer code
3 What's the difference between me and my classmates ' code? What are the respective strengths? What style of code do you prefer? If the classmate code is wrong, please help to point out where the problem.
What's different: when it comes to this problem, I use two arrays to solve the problem (because I'm worried about the lack of space in the array), and Xie classmates solve the problem with an array, my train of thought is quite clear, and his idea is relatively simple.
I prefer to Xie classmate's ideas, because the idea is relatively simple, and my thinking because the lack of space is more complicated.
Iv. Summary of this week's study
1.1 Application of one-dimensional arrays and two-dimensional arrays
int A[10],B[10][20];/*B[10][20] The use of matrices */
Char c[10],ch[10][20];/*ch[10][20] is a string array with 20 lengths per string. */
Arithmetic of 2.1string string
strcpy (A, a) copy B to a, save to a
strcmp (A, B) compare a A, a, equal output 0
Strcat (A, b) to the back of a and save to a
Strlen (a) calculates the character length of a
Deficiencies:
String strings are not skilled enough to use. Strings are easy to write wrong.
---restore content ends---
I. PTA LAB WORK
1.7-6 PTA Submission List
2. Design Ideas
Define m,n,i,sum=0,count=0. Input M,n. Apply a double loop and make the i=2 as the initial value (1 then the back loop jumps directly), and in the I loop with m%i judgment, when equal to 0 jump out I loop. If I is equal to M at the end of the jump or loop, it is equal to count++,sum=sum+m. Then wait until the M loop ends, and the output count is the number of prime numbers, and sum for them.
3 Code
4 problems encountered during the problem
Error One
At that time, the use of flag to judge, less m=n and not a prime number of cases, if the occurrence of this kind of situation code must be m, resulting in wrong thinking is not correct.
2.7-12
PTA on Submit List
2 Design ideas: The subject needs numerator the simplest fraction, first define numerator denominator and slash, and then begin to judge if Num1<=num2, will num1 as the end of the cycle, in addition to NUM1 can. Then, when num1%i&&num2%i==0 in the I loop, it is a convention number. Then continue the loop until i==num1. Conversely num2>num1 is also.
3 Code
4 Error point 1
There is no thought of the numerator greater than the denominator
3 7-21
The Problem PTA
3 Design Ideas
Define I,HH,MM. Enter HH,MM, then start judging when hh>12 and mm==0 then start I loop hh>12 how much output dang, judging if hh>=12&&mm> 0 Then start I loop this way there is a boundary problem to hh-11 output dang the last two special cases hh<12 the output hh,mm in the format, and then when mm==0, output by format.
4 Code
4 problems encountered in the subject
The calculation of the 12-point boundary is less, the boundary problem.
Two. PTA rankings for this Sunday episode
Third, the student Code mutual evaluation
1 Mutual evaluation Students ' names
Xuzhi
2. My Code, mutual evaluation of the student code
3. Where do I differ from my classmates ' code? What are the advantages? What style of code do you prefer? If the classmate code is wrong, please help point out the problem.
The same: The general idea is not much different
Differences: This is the beginning of the definition of a small day students with an initial value, the introduction of N, to avoid the situation of m==1, and I am directly using m directly to avoid
Compared with the words I think my thinking more clear, small day students of the N plus more cramped, I prefer their own code.
Iv. Summary of this week's study
1.1 Loop using the While,for statement.
1.2 Loop Nesting There is further learning to
Learning from 1.3switch sentences
The shortcomings
Loop nesting can be confusing, and switch statements are less likely to be used.
function Array Loop