首页 > 其他分享 >Programming abstractions in C阅读笔记:p184-p195

Programming abstractions in C阅读笔记:p184-p195

时间:2023-11-14 12:06:47浏览次数:40  
标签:p184 divisor abstractions int gcd odds Programming common greatest


《Programming Abstractions In C》学习第61天,p184-p195总结。

一、技术总结

1.mutual recursion

2.natural number

(1)定义

p184, If you limit the domain of possible values to the set of natural numbers,which are defined simply as the set of nonnegative integers.

3.最大公约数

/*
 * p191. 3. The greatest common divisor(g.c.d) of two nonnegative integers is the
 * largest integer that divides evenly into both. In the third century B.C., the
 * Greek mathematician Euclid discovered that the greatest common divisor of x
 * and y can always be computed as follows:
 *
 * If x is evenly divisible by y, then y is the greatest common divisor.
 * Otherwise, the greatest common divisor of x and y is always equal to the
 * greatest common divisor of y and the remainder of x divided by y.
 *
 * Use Euclid insight to write a recursive function GCD(X, Y) that computes the
 * greatest common divisor x and y.
 */
#include <stdio.h>

int gcd(int x, int y);

/*
 * function: gcd
 * Usage: int(x, y)
 * ------------
 */
int gcd(int x, int y) {
    if (x % y == 0) {
        return y;
    }
    return gcd(y, x % y);
}


int main() {
    int result;
    result = gcd(16, 28);
    printf("GCD=%d\n", result);  // GCD=4
    return 0;
}

二、英语总结

1.holistic是什么意思?

答:

(1)holistic: holism + -istic。adj. treat the whole of sth and not just a part(整体的)。

(2)holism: holos(“whole”,来自于“*sole”,完整的) + -ism(word-forming element making nouns implying a practice, system, doctrine, etc. 构成词的元素,暗示实践、制度、学说等)。u. the belief that each thing is a whole that is more important the parts that make it up,整体论。

(3)-istic: adjectival word-forming element(构成形容词的元素)。

(4)示例:p185, Maintain a holistic perspective(保持整体的观点)。

2.philosophical是什么意思?

(1)philosophical: philosophy + -ical。adj. relating to the study of philosophy(哲学的)。

(2)philosophy: philo-(“loving”) + sophia(“knowledge, wisdom”),哲学。

3.devote是什么意思?

答:de-(down from,away from, 离开) + vow(to vow“make a promise to do sth, 发誓”),即as if by vow。

(1) vt. to use sth for a particular purpose(使用)。p185,In Chapter 2 of The Art and Science of C, I devote one section to the philosophical concepts of holism and reductionnism(在《在C语言的科学与艺术》第二章,我专门用一节来介绍整体论与还原论这两个哲学概念。)

4.odds are good是什么意思?

答:

(1)odds: n. the probalility that a particular thing will or will not happend(可能性)。

(2)odds are good: There is a high probability that it will happen(可能性很大)。

(3)示例:p185,After all, when you write a program, the odds are good–even if you are an experienced programmer–that your program won’t work the first time。

三、参考资料

1. 编程

(1)Eric S.Roberts,《Programming Abstractions in C》

2. 英语

(1)Etymology Dictionary:https://www.etymonline.com

(2) Cambridage Dictionary:https://dictionary.cambridge.org

欢迎搜索及关注:编程人(a_codists)


标签:p184,divisor,abstractions,int,gcd,odds,Programming,common,greatest
From: https://blog.51cto.com/u_15137915/8364826

相关文章

  • Dynamic Programming
    目录热身198.打家劫舍62.不同路径63.不同路径II213.打家劫舍II337.打家劫舍III参考:https://cloud.tencent.com/developer/article/1692068热身斐波那契数列递归求解自顶向下,存在大量的重复计算动态规划保存中间状态,利用保存的历史状态求解问题,减少了重复计算,空间......
  • Programming Abstractions in C阅读笔记:p196
    《ProgrammingAbstractionsinC》学习第63天,p196总结。涉及到编程之外的知识,依然是读起来很费劲,需要了解作者在书中提到的人物(EdouardLucas)、地点(Benares)、神话传说(Brahma)等等。虽然深知自己做不到对人文知识,历史知识精通,但也希望能记住,从而在下次遇到的时候能够阅读下去......
  • Toyota Programming Contest 2023#7(AtCoder Beginner Contest 328)
    ToyotaProgrammingContest2023#7(AtCoderBeginnerContest328)A.NotTooHard题意:将给定的数列\(a\)中数值小于\(x\)的数累加。解题思路:模拟。代码:#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;voidsolve(){ intn,x; cin>>n>>x;......
  • The 10th Jimei University Programming Contest
    外校打星队伍,排名22/450,还算凑合吧。A.A+B问题直接枚举进制#include<bits/stdc++.h>usingnamespacestd;usingvi=vector<int>;voidsolve(){stringstr;via,b,s;cin>>str;for(autoc:str){if(c>='0'and......
  • HHKB Programming Contest 2023(AtCoder Beginner Contest 327) 赛后总结
    HHKBProgrammingContest2023(AtCoderBeginnerContest327)赛后总结又没来得及写题解。。。赛时A-ab查找ab和ba,只要其中一者存在就行。#include<bits/stdc++.h>usingnamespacestd;intn;strings;intmain(){cin>>n>>s;cout<<(s.find("a......
  • Japan Registry Services (JPRS) Programming Contest 2023 (AtCoder Beginner Contes
    JapanRegistryServices(JPRS)ProgrammingContest2023(AtCoderBeginnerContest324)赛后总结可悲的是:我没来得及写题解。TaskASame秒切。直接输入排一遍序再遍历即可。#include<bits/stdc++.h>usingnamespacestd;intn,a[101];intmain(){cin>>n;......
  • HHKB Programming Contest 2023(AtCoder Beginner Contest 327)
    HHKBProgrammingContest2023(AtCoderBeginnerContest327)A-abintmain(){IOS;strings;cin>>n>>s;boolf=false;for(inti=1;i<n;++i)if(s[i-1]=='a'&&s[i]=='b&#......
  • HHKB Programming Contest 2023(AtCoder Beginner Contest 327)
    HHKBProgrammingContest2023(AtCoderBeginnerContest327)A.ab解题思路:模拟即可。代码:#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;voidsolve(){intn;cin>>n;strings;cin>>s;for(inti=0......
  • [935] Python Programming in QGIS3
    ref:GettingStartedWithPythonProgramming(QGIS3)ref:1.4.1.UsingPyQGISinstandalonescripts ......
  • 【算法笔记】动态规划Dynamic Programming
    参考视频:5SimpleStepsforSolvingDynamicProgrammingProblems引子:最长递增子串(LongestIncreasingSubsequence,LIS)LIS([31825])=len([125])=3LIS([52863695])=len([2369])=4解决问题的三个步骤:可视化例子(visualizeexample)(“visualizee......