- 1
- 0
- 约2.73万字
- 约 88页
- 2019-04-30 发布于湖北
- 举报
指 针 指针变量的声明和初始化 指针运算符 函数的传引用调用 对指针使用const 限定符 使用传引用调用的泡沫排序法 指针表达式和指针的算术运算 指针和数组的关系 指针数组 实例研究 指向函数的指针 实例研究 如果反复随机选中已经洗好的牌,洗牌算法可能会执行无数次。这种现象称为“无限延迟” (可通过优化算法解决“无限延迟”问题) 以顺乎自然的方式制定的算法有时存在诸如无限延迟等等的微妙的性能问题。应选择不存在无限延迟现象的算法 要发第一张牌就从数组中查找等于1的数组元素deck[row][column] 。这是用嵌套的for 循环完成的,for 循环中的变量row 从0变化到3、column 从0 变化到12。怎样表示发出的每一张牌呢?因为数组suit 已经预载入了四种花色, 所以通过打印字符串suit[row]可获得花色。同样,打印字符串face[column]可获得牌的面值。我们还打印出字符串“of” 。以正确的顺序打印这些信息可以打印出每一张牌,如打印出“King of Clubs” 、“Ace of Diamonds” 下面用自顶向下逐步求精的方法描述洗牌和发牌的算法 实例研究 算法的顶层是简单的,即 Shuffle and deal 52 cards 第一次求精得出的结果为: Initialize the suit array Initialize the face array Initialize the deck array Shuffle the deck(洗牌) Deal 52 cards(发牌) “洗牌”过程求精的结果为: For each of the 52 cards Place card number in randomly selected unoccupied slot of deck (把发牌序号插入到随机选出来的未选中过的牌中) 实例研究 “发牌”过程的求精结果为: For each of the 52 cards Find card number in deck array and print face and suit of card (在数组deck中查找发牌序号并打印出该张牌的面值和花色) 把上述两个求精过程合并起来就得到第二步求精的结果: Initialize the suit array Initialize the face array Initialize the deck array For each of the 52 cards Place card number in randomly selected unoccupied slot of deck For each of the 52 cards Find card number in deck array and print face and suit of card /* 试图修改指向常量数据的常量指针 */ # includestdio.h main() { int x = 5, y; const int * const ptr = x; *ptr = 7; ptr = y; return 0; } 编译输出: Compiling FIG7_13.C: Error FIG7_13.C8: Cannot modify a const object Error FIG7_13.C9: Cannot modify a const objiect Warning FIG7_13.C11:’ptr’ is assigned a value that is never used Warning FIG7_13.C11:’y’ is deci
您可能关注的文档
最近下载
- 由汉字起源到姓名学-polyu.ppt
- 高新技术企业认定专项审计培训课件.ppt VIP
- 四年级数学下册《方程》.ppt VIP
- 一种用于修复皮肤屏障的沙棘果油组合物及其制备方法.pdf VIP
- 地铁年终总结范文.docx VIP
- 社区灾害风险评估指南及应用案例(终稿).pdf VIP
- (高清版)B-T 10095.2-2023 圆柱齿轮 ISO齿面公差分级制 第2部分:径向综合偏差的定义和允许值.pdf VIP
- 高新技术企业审计课件.pptx VIP
- 2026年高考数学压轴专项训练压轴题15立体几何19题题型归类(原卷版+解析).docx VIP
- 一种用于晒后皮肤受损的修复喷雾及其制备方法.pdf VIP
原创力文档

文档评论(0)