




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
综合练习一 打印综合练习一 打印 ASC 码表码表 在这个项目中 我们想去打印所有的ASCII码字符及相关联的十进制和二进制值 关于关于ASCII ASCII表示美国信息交换标准码 正如它的名字所暗示的 它是由美国的一个代码指定的 数字每个信息存储或传输计算机来完成 这里是关于ASCII码的重点 每个键盘字符都可以映射到数字从32 127 数字从0 到31用于特殊字符 如制表符 铃 换行符等 扩展ASCII范围从128 至255 含有专门128 个字符 如边框线等 扩展的ASCII字符是非标准化 可能会从一个操作系统类型到另一个 如PC和MAC 与Linux 标准的 ASCII 是标准化的 同样都可以跨越不同的操作系统类型 最终结果最终结果 第一步写出程序的基本框架第一步写出程序的基本框架 任何 C 程序都具有以下的基本框架 第二步添加一个具有一个变量的循环语句第二步添加一个具有一个变量的循环语句 我们想去打印所有的标准和扩展 ASCII 码的值 这就意味着循环从 0 至 255 Title Print Standard and Extended ASCII chart Source print ascii c Author Some Student Version 1 0 include main Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 1 0 include main int i for i 1 i 255 i return 0 第三步不同数据格式打印变量值第三步不同数据格式打印变量值 我们现在想使用十进制和十六进制和 ASCII 字符打印每个字符 第四步打印标题并将每列对齐第四步打印标题并将每列对齐 现在 我们将每一个字符打印出来 使它变得整洁些并给每一栏加一个标题 注意如何 选择适当的宽度打印每一栏 我们也会修改一些在我们试图打印一些如 n a 的控制符代替一些ASCLL码字符 这些 字符是一些不可打印的字符 出现的问题 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 1 0 Initial release include main int i for i 1 i 255 i printf d x c n i i i return 0 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 1 1 include main int i printf DEC HEX ASCII n for i 1 i 255 i if i 32 printf 3d 3x 5s n i i n a else printf 3d 3x 5c n i i i return 0 第五步使它更适应屏幕第五步使它更适应屏幕 现在你可能注意到 没有太多的屏幕是被用来横跨宽 不仅如此 你必须退回通过输出 缓冲区以便看到更低的数字 这样效率更高 如何255行被分割成5栏52行的话就更容易 阅读 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 2 0 include main int i printf DEC HEX ASC DEC HEX ASC DEC HEX ASC printf DEC HEX ASC DEC HEX ASC n for i 1 i 51 i if i 32 printf 3d 3x 3s i i n a else printf 3d 3x 3c i i i printf 3d 3x 3c 3d 3x 3c i 51 i 51 i 51 i 102 i 102 i 102 printf 3d 3x 3c 3d 3x 3c n i 153 i 153 i 153 i 204 i 204 i 204 return 0 第六步打印一些边框第六步打印一些边框 现在 假如需要的话 我们有一个可以在一张A4纸上合理的打印ASCII的图表 我们 现在需要做的是给一张表格用一个扩展 ASCII 特殊字符制作一个边框 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 2 1 include main int i a for a 0 a 71 a printf c 205 printf n printf DEC HEX ASC DEC HEX ASC DEC HEX ASC printf DEC HEX ASC DEC HEX ASC n for a 0 a 71 a printf c 205 printf n for i 1 i 51 i if i 32 printf 3d 3x 3s i i n a else printf 3d 3x 3c i i i printf 3d 3x 3c 3d 3x 3c i 51 i 51 i 51 i 102 i 102 i 102 printf 3d 3x 3c 3d 3x 3c n i 153 i 153 i 153 i 204 i 204 i 204 for a 0 a 71 a printf c 205 printf n return 0 第七步第七步 将一些通用的功能转换成函数将一些通用的功能转换成函数 进阶进阶 最后的阶段是介绍一个简单函数的概念 一个方法一个C源程序的一个模块 这个模块可以在项目的任何 地方被调用 包括函数的内部 我们从最后一步了解到 一段代码被重复使用了三次 这将是一个方法的理想条件 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 2 2 include void pretty line int a for a 0 a 71 a printf c 205 printf n return main int i Print the top border line pretty line Print the heading printf DEC HEX ASC DEC HEX ASC DEC HEX ASC printf DEC HEX ASC DEC HEX ASC n Print the middle border line pretty line for i 1 i 51 i if i 32 printf 3d 3x 3s i i n a else printf 3d 3x 3c i i i printf 3d 3x 3c 3d 3x 3c i 51 i 51 i 51 i 102 i 102 i 102 printf 3d 3x 3c 3d 3x 3c n i 153 i 153 i 153 i 204 i 204 i 204 Print the bottom border line pretty line return 0 第八步第八步 扩展打印函数的边界扩展打印函数的边界 进阶进阶 这一点它看起来不错 为了使用合适的拐角和分隔栏获得一个专业的边框 我们必须去 使用一些扩展字符中的特殊字符 以下是三种类型的线条是必要的 顶线 标题下的线条 中间线条 底线 一个方法可以有一个通过调用时传入的参数 参数可以是任何类型的 在topic2中讨 论 我们就指派一个整数类型作为第一个参数 调用的线条类型如下 0 是顶线 1 是中线 2 是底线 现在 我们观察每一个线条 除了第一个 最后一个和和分栏符 它们基本相同 我们将使用一个例子去选择线条的样式 通过一个变量来改变调用的左右中的符号 最后 我们可以使用嵌套的三个操作打印线条 实际打印的符号是否是根据第一条 a 0 是否是最后一条 a 70 或者是否是栏分割位置 a 14 0 Title Print Standard and Extended ASCII chart Source print ascii c Author NJCIT Version 3 0 include This function prints a line accros the screen The line can be one of the following types line type 0 The top line line type 1 The middle line line type 2 the bottom line void pretty line int line type char left char right char mid char char ext char int a Set left right and mid characters depending on line type switch line type case 0 Top line left char 213 right char 184 mid char 209 break case 1 Middle line left char 198 right char 181 mid char 216 break case 2 Bottom line left char 212 right char 190 mid char 207 break default Invalid argument passed to us left char right char mid char for a 0 a 71 a ext char a 0 left char a 70 right char a 14 0 mid char 205 printf c ext char printf n left char 198 right char 181 mid char 216 break case 2 Bottom line left char 212 right char 190 mid char 207 break default Invalid argument passed to us left char right char mid char for a 0 a 71 a ext char a 0 left char a 70 right char a 14 0 mid char 205 printf c ext char printf n return main int i Print the top border line pretty line 0 Print the heading printf DEC HEX ASC DEC HEX ASC DEC HEX ASC printf DEC HEX ASC DEC HEX ASC n Print the middle border line pretty line 1 Print the ASCII ta
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 师徒结对活动典礼讲话稿范文
- 五年级数学速算训练题及解答
- 酒店客户服务标准流程与管理要点
- 医院床位动态管理与调配策略
- 建筑施工项目进度管理实务及操作指南
- 电梯改造检修详细施工计划书
- 高温锡膏安全使用与MSDS要点
- 住宅楼质量维权投诉书范本
- 网络招聘渠道效果分析报告
- 高效团队建设培训课程与案例分析
- 体育健康知识教案课件
- 儿童早期矫治科普知识讲座
- 医院培训课件:《前列腺癌的诊治指南》
- 《工程结构抗震设计》课件 第5章-多层及高层钢筋混凝土房屋抗震设计
- 人民调解投标方案(完整技术标)
- ZSMC之山智控 K5系列说明书V1.6-中文
- 海康威视枪机摄像机检测报告
- 【超星尔雅学习通】商法的思维网课章节答案
- 新增临时排水管方案
- GB/T 5796.3-2022梯形螺纹第3部分:基本尺寸
- 第七章-辐射防护分析课件
评论
0/150
提交评论