17645190554逻辑结构程序设计实验报告

上传人:hs****ma 文档编号:473606155 上传时间:2023-11-25 格式:DOC 页数:4 大小:44KB
返回 下载 相关 举报
17645190554逻辑结构程序设计实验报告_第1页
第1页 / 共4页
17645190554逻辑结构程序设计实验报告_第2页
第2页 / 共4页
17645190554逻辑结构程序设计实验报告_第3页
第3页 / 共4页
17645190554逻辑结构程序设计实验报告_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《17645190554逻辑结构程序设计实验报告》由会员分享,可在线阅读,更多相关《17645190554逻辑结构程序设计实验报告(4页珍藏版)》请在金锄头文库上搜索。

1、宁夏师范学院数学与计算机科学学院c程序设计实验报告实验序号:04 实验项目名称:逻辑结构程序设计学号姓名专业、班实验地点指导教师时间一、 实验目的及要求1、了解C语言表示逻辑量的方法2、正确使用逻辑运算符和逻辑表达式,掌握if语句和switch语句3、结合程序掌握一些简单算法,并学习调试程序二、实验设备(环境)及要求1. 硬件:PC机;2. 软件:Windows操作系统、TurboC+ 3.0 。三、实验内容与步骤 实验内容:1. 有一函数: x (x1) y = 2x-1 (1x10) 3x-11 (x10)写一程序,用scanf函数输入x,输出y值。 2. 编程实现:给出一个百分制成绩,要

2、求输出成绩等级A、B、C、D、E。90分以上为A,8189分为B,7079分为C,6069分为D,60分以下为E。3. 给一个不多于5位的正整数,要求:求出它是几位数;分别打印出每一位数字;按逆序打印出各位数字,例如原数为321,应输出123。1. #include void main ()int a,b;printf(Please input a:n);scanf(%d,&a);if (a1)printf(b= %d,a);else if(1=a=10)b=3*a-11; printf(b= %d,b);2.#include void main()float score; char grad

3、e; printf(please input scores:); scanf(%f,&score); while(score100|score0) printf(nWrong!); scanf(%f,&score); switch(int)(score/10) case 10: case 9: grade=A;break; case 8: grade=B;break; case 7: grade=C;break; case 6: grade=D;break; case 5: case 4: case 3: case 2: case 1: case 0: grade=E; printf(scor

4、e:%5.1f,grade:%c n,score,grade); 3.#include #include void main()long int num; int indiv,ten,hundred,thousand,ten_thousand,place; printf(please input a number:); scanf(%ld,&num); if(num9999) place=5; else if(num999) place=4; else if(num99) place=3; else if(num9) place=2; else place=1; printf(place=%d

5、n,place); printf(Each number:); ten_thousand=num/10000; thousand=(int)(num-ten_thousand*10000)/1000; hundred=(int)(num-ten_thousand*10000-thousand*1000)/100; ten=(int)(num-ten_thousand*10000-thousand*1000-hundred*100)/10; switch(place) case 5: printf(%d,%d,%d,%d,%d,ten_thousand,thousand,hundred,ten,

6、indiv); printf(nChanged number:); printf(%d,%d,%d,%d,%dn,indiv,ten,hundred,thousand,ten_thousand); break; case 4: printf(%d,%d,%d,%d,thousand,hundred,ten,indiv); printf(nChanged number:); printf(%d,%d,%d,%dn,indiv,ten,hundred,thousand); break; case 3: printf(%d,%d,%d,hundred,ten,indiv); printf(nChan

7、ged number:); printf(%d,%d,%dn,indiv,ten,hundred); break; case 2: printf(%d,%d,ten,indiv); printf(nChanged number:); printf(%d,%dn,indiv,ten); break; case 1:printf(%d,indiv); printf(nChanged number:); printf(%dn,indiv); break; 实验步骤(1)启动TC+3.0,新建一个C文件;(2)输入程序;(3)保存文件;(4)编译源程序,观察屏幕上显示的编译信息,修改出现的错误,直到编译成功;(5)连接程序、运行程序,观察分析运行结果。四、实验结果与数据处理五、分析与讨论六、教师评语签名: 日期: 年 月 日 成绩

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号