C-Bo class work 11

A week working head

This work belongs to that course C Programming Language I
Where the job requires https://edu.cnblogs.com/campus/zswxy/CST2019-3/homework/10130
My goal in this Course is Learn simple self-compiled code base, entry C language.
This job helped me in terms of the specific goals Function requires students to master various types of defined functions, calls and affirm familiar with the scope of variables, life cycle and storage types
references "China University of MOOC" "Baidu," "mind map" "C language Chinese net"

# A week job

    1. PTA lab assignments
    1. Code peer assessment
    1. summarize

1.PTA lab assignments

1.1 题目名:
统计某类完全平方数 
内容描述:本题要求实现一个函数,判断任一给定整数N是否满足条件:它是完全平方数,又至少有两位数字相同,如144、676等。

函数接口定义:
int IsTheNumber ( const int N );
其中N是用户传入的参数。如果N满足条件,则该函数必须返回1,否则返回0。
 1.1.1数据处理
* 1.数据表达:用了变量 i,n,flag,tmp;
   分别代表行数和循环累加,属于整型变量。
用 int a[10] = {0};变量代表数组利用入,属于整型变量。
* 2.数据处理:
数据用到的表达式:赋值 如把int n=N;算术运算符利用累加和除法,关系运算符比较 
流程结构用for语句和判断语句if。

1.1.2 Screenshot experiment code

1.1.3 build test data

Input data Output Data Explanation
23 1879
56 999
45 788

1.1.4 PTA submit a list and description

PTA submit a list

提交列表说明:
* 1.答案正确:在dev-c++上编译了整整两天,开始的时候一直写不出来,没有思路,简直不知如何下手,幸运得高人指点,有自己思路,但在编译过程中出现各种奇葩错误,把{打成了【,少了do-while语句的do,在viod()语句后加分号;改了好久;
## 1.2 题目2

Description: figures and statistics is the number 5

本题要求实现两个函数:一个函数判断给定正整数的各位数字之和是否等于5;另一个函数统计给定区间内有多少个满足上述要求的整数,并计算这些整数的和。

函数接口定义:
int is( int number );
void count_sum( int a, int b );
函数is判断number的各位数字之和是否等于5,是则返回1,否则返回0。

函数count_sum利用函数is统计给定区间[a, b]内有多少个满足上述要求(即令is返回1)的整数,并计算这些整数的和。最后按照格式

count = 满足条件的整数个数, sum = 这些整数的和
1.2.1 数据处理 :
* 1.数据表达:用了变量j,n,i,代表整数,用于循环,属于整型变量。
用变量num,代表累加和变量定义,属于整型变量。
* 2.数据处理:
数据用到的表达式:赋值 如把i=2;    算术运算符利用累加和除法,关系运算符比较 i <= n;
流程结构 ;用循环结构for语句,函数的运用,if-else语句;顺序结构。

1.2.2 Code Screenshot

1.2.3 build test data

Input data Output Data Explanation
104 999 104 is counted.count = 15, sum = 3720

1.2.4 PTA submit a list and description

* 1.编译错误:前提是开始在dev-c++上运行出现了很多次,最开始出现很多错误,一个一个的找。#include<math.h>就这一个改了3次才成功,最开始漏了打,后来还出现include少了后面的e,彻底记住这个教训了。还有printf("%d\n",num);少了分号;

2. Code peer assessment

2 parts of the code to find the students, and their own code comparison, the proposed peer review of code to try to find coding style quite different.
First student: deep plum number

  • <1> students Code screenshot

  • <1.1> own Code Screenshot

对比小结:
* 1.都用了int <math.h>,运用了数学文件,不过我用的是开平方跟,她用除于2,对半分,各有各的优势。
* 2.我们用的变量不同,我的用了break语句,而她直接用赋值b=1来判断if成立条件。
* 3.他的排版比我的简洁,应该像他多学习。

The second student: Triangle character

  • <1>. Screenshot students Code *

<2>. Code own theme

对比小结:
* 1.她的用了get char(),输入一个字符;我们定义变量不同
* 2.都用两个for语句循环搞定了,不过我不能理解她最后还用m--是什莫意思;
* 3.我觉的我的格式比她规范一点;

3. The study concluded (15 points)

3.1 learning progress bar

Week / Date This week the time spent Lines of code Learned knowledge Introduction to the relatively confusing issue
The first week of 10.01-10.07 26 hours Line 65 Temperature Conversion Why to themselves to install MinCW-w64
The second week of 10.09-10.12 22 hours 66 lines It was converting Celsius and Fahrenheit. Note: F = C × 9/5 + 32, a temperature value is taken float type About temperature conversion formulas
The third week of 10.14-10.17 20 hours Line 85 Significance of Circulating structure for,% meaning of section, sum of Use item specific aspects, related meanings
The fourth week of 10.23-10.26 14 hours Line 55 Meaning to write function, semicolon know, how to use the for statement How to determine prime numbers easier to write programs
第五周10.30-11.02 22小时 75行 熟悉多分支结构、字符型数据类型 逻辑运算符利用,算数优先级从那边开始运算
第六周10.30-11.02 22小时 75行 熟悉多分支结构、字符型数据类型 逻辑运算符利用,算数优先级从那边开始运算
第七周11.05-11.07 04小时 35行 分支结构 熟悉多分支结构switch语句的使用 for语句的插入和分支的陷入
第八周11.10-11.15 06小时 65行 for语句确定循环次数,while明确循环终止条件,do-while语句是必须要执行一次 二进制与十进制转换
第九周11.18-11.21 10小时 98行 continue表示结束本次循环,而不终止整个循环的执行。而是结束本次循环,进行下一次循环 没有看懂for语句使用
第十周11.26-11.29 8小时 118行 复习循环嵌套语句,综合介绍循环结构的程序设计,同学讲解代码有关于换算问题,for语句的使用 硬币的换算
第十一周12.1-12.6 30小时 96行 掌握各种类型函数的定义、调用和申明,熟悉变量的作用域、生存周期和存储类型 对于函数的使用还有很大问题

3.2 累积代码行和博客字数

3.3 学习内容总结和感悟

3.3.1 学习内容总结

整理本周学习的主要知识点有:

3.3.2 学习体会

(1):定义在函数内部的变量称为局部变量(Local Variable),它的作用域仅限于函数内部, 离开该函数后就是无效的,再使用就会报错;
(2):
  • 1) 在 main 函数中定义的变量也是局部变量,只能在 main 函数中使用;同时,main 函数中也不能使用其它函数中定义的变量。main 函数也是一个函数,与其它函数地位平等。

  • 2) 形参变量、在函数体内定义的变量都是局部变量。实参给形参传值的过程也就是给局部变量赋值的过程。

  • 3) 可以在不同的函数中使用相同的变量名,它们表示不同的数据,分配不同的内存,互不干扰,也不会发生混淆。

  • 4) 在语句块中也可定义变量,它的作用域只限于当前语句块。

    (3)例句说明:
int f1(int a)
{
    int b,c;  //a,b,c仅在函数f1()内有效
    return a+b+c;
}
int main()
{
    int m,n;  //m,n仅在函数main()内有效
    return 0;

Guess you like

Origin www.cnblogs.com/huqingqing2/p/11994726.html