This work belongs courses | C language I work 09 |
---|---|
Where the job requires | Skilled loop, review the break statement, continue statement grasp |
My aim in this course | Learn to use statements continue to review and master the break statement |
In particular aspects of the job which helped me achieve goals | Use break statement and continue statement on the role of loop |
references | C language I work 09 |
PTA lab assignments
A topic
7-2 change coin
data processing
- Data are expressed: Defines the count, num1, num2, num5, wherein penny num1, num2 is 2 cents, num5 is five cents, count change is the change method. According to claim 5 points, 2 points and 1 point the number of coins sequentially in descending order, outputs various exchange methods. Each line of output change one kind of method, in the format: "fen5: 5 minutes number of coins, fen2: 2 minutes number of coins, fen1: 1 min number of coins, total: The total number of coins." The last line of output "count = number of transducers Method."
data processing:
include<stdio.h>
main int ()
{
defined change money
output changeChange the law to change the definition count, penny num1, two cents num2, five cents num5
defined for A beginning is zero
change can change several times by five cents, the total circulation
coins can be used two cents cycle several times, total cycle
change cycle can be used several times a penny, total cycle {
if 5 * num5 + 2 * num2 + num1 == money
for a cumulative
frequency using the output of five cents, penny times, the number of two cents
}
}Method of changing the output change
return 0;
Screenshot experiment code
Create test data
Input data | Output Data | Explanation |
---|---|---|
8 | fen5:1,fen2:1,fen1:1,total:3 count=1 | 8, there is a change for A |
10 | fen5:1,fen2:2,fen1:1,total:4 fen5:1,fen2:1,fen1:3,total:5 count=2 | There are two 10 change for A |
12 | fen5:1,fen2:3,fen1:1,total:5 fen5:1,fen2:2,fen1:3,total:6 fen5:1,fen2:1,fen1:5,total:7 count=3 | 12, there are three change for A |
PTA submit a list and description
- Compile Error: This error appears on the aid, lack of attention to writing a semicolon at the time of writing for loop, primarily brackets did not write a semicolon, a comma, resulting in compilation error, after careful examination revealed errors and correct an error
Topic two
7-6 draw squares together with Obama
data processing
- Data are expressed: defines variables i and j, n-, a, where a is the character variable, i, and j is an integer variable, the output of a given character drawn by a square. But noted that the line spacing is larger than the column spacing, so in order to make the results look more like a square, the number of lines we output is actually 50% of the number of columns (rounded to the nearest integer).
data processing:
include<stdio.h>
main int ()
{
define integer variables i and j for the loop variable n
is defined a character variable
output n
output a
when n% 2 = 0 when
i and accumulating cycle
{
j cycle and accumulating
{
enter a
}换行 }
When n% 2 is not equal to 0,
i and accumulating the second cycle
{
J and accumulating the second cycle
{
output A
}
newline
}
return 0;
}
Screenshot experiment code
Create test data
Input data | Output Data | Explanation |
---|---|---|
5a | aaaaa aaaaa aaaaa | a composition of a rectangle about |
6b | bbbbbb bbbbbb bbbbbb | b Composition b, on the rectangular |
10c | cccccccccc cccccccccc cccccccccc cccccccccc cccccccccc | c composed of square on c |
PTA submit a list and description
- Wrong Answer: compiled on aid, in for (i = 1; i <= n / 2; i ++) this place is written n rather than n / 2, after debugging found the problem
Code peer assessment
Students Code
My code
- Comparing the code, and I found that the difference is that the students: I use a loop of three groups for a fifth, two points and one point circulated, but he only took two, and I use the if statement if (5 Num5 +2 num2 num1 == + Money), but he spent a lot of expression
- In terms of format he wants to look better than I do, I need a lot of attention
Students Code
My code
- Comparing the code found in the use of the for loop I use multiple sets, he used less, and I used the statement to determine if the decimal is equal to 0
- I should be easy to understand, he's relatively simple, but there is always their own way
Learning progress
Learning progress bar
Cumulative code and blog words
Learn insights and experience
Learn sentiment
- Work can now be completed in a timely manner and quickly, but often not pay attention to their own definition of the variables of the phenomenon still exists
- Review of the loop, and further study the break statement and continue statement the new school
Realizations
- This is my first homework ahead of time, explained to me c language learning has been greatly improved
- Common mistake is to not pay attention to their own definition of variables, not always distinguish case, a stupid mistake compilation errors always occur
- Near the end of the period, and many did not grasp the knowledge points, needs a lot of review and ask teachers and students to solve, at least to ensure that no hanging branches