C语言编程作业:货币兑换与时间转换程序

需积分: 0 1 下载量 37 浏览量 更新于2024-07-02 收藏 770KB PDF 举报
"这篇资源包含了《C语言程序设计现代方法》一书的第8次作业的编程题答案,包括编程题2、3、4、5的详细代码实现,这些题目涉及了货币换算、时间转换以及计算和的功能。" 《C语言程序设计现代方法》是学习C语言的经典教材之一,本资源提供了北航课程相关的C语言编程作业答案,有助于学生巩固和理解书中所学知识。以下是每个编程题目的详解: 编程题2:这是一个货币换算的程序,用户输入美元金额,程序将转换成25美分、10美分、5美分和1美分硬币的数量。`change`函数接收美元金额和四个指针参数,分别用于存储不同面值硬币的数量。通过整数除法和取余运算,计算出各种硬币的数量。 编程题3:该程序要求用户输入时间(小时、分钟、秒),然后将时间转换为总秒数。`secs`函数接受总秒数的指针和三个整数参数,通过简单的乘法和加法运算,将输入的时间转换为总秒数。 编程题4:与编程题3相反,这个程序接收一个总的秒数,然后将其转换为小时、分钟和秒。`time`函数通过除法和取余运算,将总秒数拆分成小时、分钟和秒。 编程题5:这个题目是计算三个整数之和的,`computeSum`函数接收一个整数指针和三个整数参数,计算它们的和并将结果存储在指针指向的位置。虽然题目没有给出完整代码,但可以推断其结构是简单的加法操作。 这些编程题旨在训练学生的C语言基础,如输入输出处理、变量的使用、函数的定义与调用、指针操作以及基本的数学运算。通过实践这些题目,学生可以加深对C语言控制流程、数据类型和内存管理的理解。同时,解决实际问题的能力也会得到提升,这在后续更复杂的编程项目中是至关重要的。

create table Students ( Sno char(12), Sname VARCHAR(20) not null, Ssex char(2), Syear smallint, Sdept varchar(20) )charset=utf8; CREATE table Courses ( Cno char(8), Cname VARCHAR(20) not null, PreCno VARCHAR(30), Credit char(4) )charset=utf8; create TABLE SC ( Sno char(12), cno char(8), Score char(8) )charset=utf8; INSERT into students VALUES("200201","张三","男",2001,"人工智能学院"); INSERT into students VALUES("200202","李四","男",2002,"人工智能学院"); INSERT into students VALUES("200203","王五","女",2003,"计算机学院"); INSERT into students VALUES("200204","赵六","男",2000,"计算机学院"); INSERT into students VALUES("200205","孙琦","女",2002,"经管学院"); INSERT into students VALUES("200206","刘八","男",2001,"经管学院"); INSERT into students VALUES("200207","曾九","女",2002,"美术学院"); INSERT into students VALUES("200208","陈拾","女",2004,"美术学院"); SELECT * from Students; INSERT into courses VALUES("1001","数据库","程序设计基础","3"); INSERT into courses VALUES("1002","大学语文",null,"2"); INSERT into courses VALUES("1003","高等数学",null,"3"); INSERT into courses VALUES("1004","数据结构",null,"3"); INSERT into courses VALUES("1005","计算机导论",null,"3"); INSERT into courses VALUES("1006","计算机网络",null,"4"); INSERT into courses VALUES("1007","程序设计基础",null,"5"); INSERT into courses VALUES("1008","Java","数据结构","5"); SELECT * from courses; INSERT into SC VALUES("200201","1001","90"); INSERT into SC VALUES("200201","1002","85"); INSERT into SC VALUES("200202","1001","85"); INSERT into SC VALUES("200203","1002","75"); INSERT into SC VALUES("200202","1002","55"); INSERT into SC VALUES("200202","1003","95"); INSERT into SC VALUES("200206","1007","65"); INSERT into SC VALUES("200204","1008","77"); INSERT into SC VALUES("200205","1004","89"); INSERT into SC VALUES("200208","1007","45"); SELECT * from courses; 运行以上SQL代码,查询至少有5名男生的专业

2023-05-26 上传