This work belongs to the curriculum | C Programming Language II |
---|---|
Where the job requires | C language I work 08 |
My aim in this course is | C language proficiency |
This job helped me achieve that goal in terms of specific | PTA teacher assigned on the type of job |
references | The basic syntax of Markdown |
A, PTA lab assignments ranking
1.1 seek digit integer and the sum of the digits
For a given positive integer N, the number of bits required it and the sum of the digits.
Input format:
Enter a given line does not exceed ten square of nine positive integer N.
Output format:
output bits of the N and the sum of the digits in a row, separated by a space.
Sample input:
321
Output Sample:
36
1.1.1 Data Processing
Data are expressed: using the integer variable N, A, I = 0, SUM = 0;
SUM denotes the sum of the digits, i denotes the number of bits it,
the data processing: by the while statement,
with the expression sum + = a% 10 divided by the number of modulo 10
with the modulo expression a / = 10 divided by the number of 10
plus one followed by the use of the expression i ++ i
Fake code
int main(void)
{
int N, a, i = 0, sum = 0;
scanf("%d", &N);
a = N;
while (a)
{
sum += a % 10;
a /= 10;
i++;
}
printf("%d %d\n", i, sum);
return 0;
}
1.1.2 Screenshot experiment code
Input data | Output Data | Description
- | - | -
33 is | 3. 6 | 2 33 is its median and its you figures are. 6
356 | 3 14 | 356 and its median you figures 3 and 14
466 | 3 16 | 466 3 and its median is the sum of the digits is 16
1.1.4 PTA submit a list and description
Submit a list of instructions:
Compiler compiler in advance, so there is no mistake
1.2 crawling worms
A length of 1 inch worm, the bottom of an inch deep N well. The worm is known inch per minute to climb U, but must then rest for 1 minute to climb. During the break, the worm has dropped D inch. In this way, climb and glide repeated. I ask, how long it takes to climb out of worms well? Here requires less than 1 minute in 1 minutes, and assuming that as long as a particular climb during the worm's head reached the top of the well, then the worm to complete the task. Initially, the worm is lying at the bottom (i.e., the height of 0).
Input format:
input given three positive integer N in a row sequence, U, D, where D <U, N does not exceed 100.
Output Format:
Output of a worm climb out of the well in a row, in minutes.
Sample input:
1231
Output Sample:
11
1.2.1 Data Processing
Data are expressed: using the integer variable N, U, D, L, t down D inch, m represents a height, N represents the deep N-inch, to climb U inch
Data processing: by the while statement and if statements,
with the expression of t represents the time change of the formula;
with an expression m = m + U represents worm crawling height;
with the expression m> = N, break; m = mD; t ++; represents worm climb out time
pseudocode
include<stdio.h>
int main()
{
int N, U, D, t, m;
scanf("%d%d%d", &N,&U,&D);
m=t=0;
while(m<N){
t++;
m=m+U;
if(m>=N)
break;
m=m-D;
t++;
}
printf("%d",t);
return 0;
}
1.2.2 Code Screenshot
1.2.3 build test data
input data | Output Data | Description
- | - | -
15 5 3 | 11 | 15 inches deep wells, worms per minute to climb 5-inch, worm takes 11 minutes to climb out of the well
105 2 | 5 | deep 10-inch wells, worms per minute to climb 5-inch, worm takes 10 minutes to climb out of the well
14 5 3 | 11 | deep 14-inch wells, worms per minute to climb 5 inch , the worm takes 11 minutes to climb out of the well
1.2.4 PTA submit a list and description
Compile Error: Variable not unified, and time t m wrong
compile correctly: changed it back.
2. Code peer assessment
Students Code
of my
classmates code complex variables, and questions asked as N, so feel closer to the subject requirements.
summarize
week | This week the time spent lines of code | Learned knowledge Introduction |
---|---|---|
fifth week | 4 hours | 20 lines |
Sixth Week | 8 hours | Line 27 |
Week Seven | 10 hours | 75 lines |
Eighth Week | 12 hours | 120 lines |
Week Nine | 16 hours | 170 line |
The tenth week | 20 hours | 210 line |
Week 11 | 22 hours | 320 |
3.3 Summary and perception of learning content
3.3.2 Learning Experience
Feel the use of the structure of general circulation, but circulation structure easy to understand, each write cycle structure as long as a good grasp of the cycle start and termination conditions to feel easier, but also do without the help of mathematical topics.
structure using do-while the less skilled, feeling that each write do-while will be very troublesome, but also need to work.