This work belongs to the curriculum | C Programming Language II |
---|---|
Where the job requires | C language blog I work 09 |
My aim in this course is | C language proficiency |
In particular aspects of the job which helped me achieve goals | Mastered for circulation, learned to break statement and continue statement |
references | The basic syntax of Markdown |
A .PTA lab assignments
1. painting box together with Obama
Topic Description: US President Barack Obama not only appeal to everyone to learn programming, and even set an example to write code, write computer code to become the first president in American history. The end of 2014, to celebrate the "Computer Science Education Week" was officially launched, Obama wrote the computer code is very simple: draw a square on the screen. Now you draw it with him!
Input formats:
输入在一行中给出正方形边长N(3≤N≤21)和组成正方形边的某种字符C,间隔一个空格。
Output formats:
输出由给定字符C画出的正方形。但是注意到行间距比列间距大,所以为了让结果看上去更像正方形,我们输出的行数实际上是列数的50%(四舍五入取整)。
Sample input:
10 a
Sample output:
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
aaaaaaaaaa
(1) Data processing
数据表达:
用了整形变量 n,i,j;和字符型变量 a;
n代表正方形的边长
j,i分别用来表示两个控制变量
Data processing: pseudocode
开始
int n,i,j;//输入整型变量
char a;//字符型变量
scanf("%d ",&n);
scanf("%c",&a);
if(n%2==0) //当n为偶数时
for(i=1;i<=n/2;i++) //n/2行
{
for(j=1;j<=n;j++) //每行n个
{
printf("%c",a);//输出a
}
printf("\n");//换行
}
if(n%2!=0) //当n为奇数时
for(i=1;i<=(n+1)/2;i++) //(n+1)/2行
{
for(j=1;j<=n;j++) //每行n个
{
printf("%c",a);//输出a
}
printf("\n");//换行
}
return 0;
}
(2) Experimental Code screenshot
(3) making test data
Input data | Output Data | Explanation |
---|---|---|
5 a | aaaaa aaaaa aaaaa | For the long side 5a, a block width 3a |
6 a | aaaaaa aaaaaa aaaaaa | For the long side 6a, a block width 3a |
4 a | aaaa aaaa | For the long side 4a, a block width 2a |
(4) PTA submit a list and description
Submit a list of instructions
1.编译错误:第8行中少了一个=
2.编译错误:第17行中少了一个!
3.答案正确:在第8行上加一个=,在第17行中加一个!
2. Print ninety-nine formulas table
Topic Description: The following is a complete list of lower triangular ninety-nine formulas:
11=1
12=2 22=4
13=3 23=6 33=9
14=4 24=8 34=12 44=16
15=5 25=10 35=15 45=20 55=25
16=6 26=12 36=18 46=24 56=30 66=36
17=7 27=14 37=21 47=28 57=35 67=42 77=49
18=8 28=16 38=24 48=32 58=40 68=48 78=56 88=64
19=9 29=18 39=27 49. 5 = 36 9. 6 = 45 9. 7 = 54 9. 8 = 63 9 = 72 9 9 = 81
The title requirements for any given a positive integer N, the output from one 1 to N * N table portion formulas.
Input formats:
输入在一行中给出一个正整数N(1≤N≤9)。
Output formats:
输出下三角N*N部分口诀表,其中等号右边数字占4位、左对齐。
Sample input:
4
Sample output:
1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
1*4=4 2*4=8 3*4=12 4*4=16
(1) Data processing
数据表达:用了整型变量N,i,j
N代表任意给定的一位正整数
i和j分别表示九九乘方表中的数字
Data are expressed: pseudocode
开始
int main()
{
int N;//输入整型变量
int i,j;//输入整型变量
scanf("%d",&N);
for(j=1;j<=N;j++)//N行
{
for(i=1;i<=j;i++)//每行j个
printf("%d*%d=%-4d",i,j,i*j);//输出i,j,i*j
printf("\n");//换行
}
}
(2) Experimental Code screenshot
(3) making test data
Input data | Output Data | Explanation |
---|---|---|
1 | 1*1=1 | Table 1 is output to the formulas |
2 | 11=1 12=2 2*2=4 | Outputted from the partial formulas of Table 1-2 |
3 | 11=1 12=2 22=4 13=3 23=6 33=9 | Outputted from the partial formulas 1-3 Table |
(4) PTA submit a list and description
Submit a list of instructions
1.编译错误:第6行括号中没有加,
2.部分正确:第10行没有写i*j
3.部分正确:第10行没有写i*j
4.全部正确:在第6行中加, 第10行中加i*j
II. Code peer review
Students Code:
Own codes:
Compare
(1)第一份代码用了double浮点型和char字符型,结构上该同学的更加整洁美观,也更容易懂。
(2)第二份的代码用了char op字符型变量,而我用的char 定义不同,他用到了if-else,而我只用了if。
(3)第一份代码行只有16行,而我有27行,他的比我的更加简单,也节省空间。
III. Learning summary
1. Learn the progress bar
Week / Date | This week the time spent | Lines of code | Learned knowledge Introduction | Currently more confusing issues |
---|---|---|---|---|
the fourth week | 7 hours | 100 lines | Hello World is displayed on the screen! | no |
fifth week | 8 hours | 100 lines | Seeking corresponding Fahrenheit Celsius | no |
Sixth Week | 21 hours | 400 lines | How MinGW-w64 to compile C program | no |
Week Seven | 24 hours | Line 478 | Use an if statement to complete a variety of mathematical procedures | For && usage do not know, now operating unskilled |
Eighth Week | 20 hours | 349 line | Master cycle program designed to be used for loop to achieve a specified number of times | no |
Week Nine | 23 hours | 264 line | Learn to use a custom function | Currently less skilled |
The tenth week | 22 hours | 167 line | Familiar with multi-branch structure, character data types and logical operators | Yet completely familiar |
Week 11 | 18 hours | 150 lines | Familiar with multi-branch structure of the switch statement | no |
Week Twelve | 16 hours | 130 line | Familiar with while and do-while structure to solve the problem | There is less skilled |
Week 13 | 15 hours | 120 lines | Familiar with for structure, understand and master the break statement and continue statement | There is less skilled continue statement |
2. Cumulative lines of code words and blog
time | Words blog | The number of lines of code |
---|---|---|
the fourth week | 525 | 50 |
fifth week | 645 | 100 |
Sixth Week | 645 | 400 |
Week Seven | 2659 | 478 |
Eighth Week | 3586 | 597 |
Week Nine | 4769 | 698 |
The tenth week | 5897 | 787 |
Week 11 | 6289 | 897 |
Week Twelve | 7594 | 1056 |
Week 13 | 8679 | 1170 |
3. insights and learning content summary
(1) learning content summary
(2) learning experience
C language learning for some time, the more we learn the more difficult back last week to learn the do-while statement this week to learn the break statement and continue statement, and know the difference between these two statements, but also added a coding skills, but also learned new knowledge of C language, now not as hard when compiled code, but still less skilled, but the topic has become increasingly difficult, and I still lack a lot of exercise, but also a lot of lack of knowledge, I after also need to practice harder and spend more time here, towards my goal