以文本方式查看主题 - 中文XML论坛 - 专业的XML技术讨论区 (http://bbs.xml.org.cn/index.asp) -- 『 C/C++编程思想 』 (http://bbs.xml.org.cn/list.asp?boardid=61) ---- 请问众多高手,这个程序应该怎么编写呀??????? (http://bbs.xml.org.cn/dispbbs.asp?boardid=61&rootid=&id=53691) |
-- 作者:yy2954 -- 发布时间:10/12/2007 4:09:00 PM -- 请问众多高手,这个程序应该怎么编写呀??????? Lab 1. Coin-changing and the Calculator COMP Structured Programming United International College ___________________________________________________________________________ Now you are going to be a programming expert by exploring more in C programming! In this lab, you need to complete two tasks: a coin-changing program and a C calculator. Task 1: Coin-Changing You will write a coin-changing program for lab1. First, ask the user for the amount in For example, your program first prompts the user for the amount in HKD by displaying the following message. Please input the amount in Hong Kong dollars: If the input is 56.30, the output should be 10-dollar coin: 5 Task 2: A Calculator Your second task is to write an integer arithmetic calculator. Your calculator program should prompt the following UI (user interface) to the user. After the user input the expression in the correct format, your program calculates and displays the result. If the user inputs a illegal operator, your program should print the following message and ask the user to re-input it. Sorry, you’ve input an wrong operator. Please enter the arithmetic expressions again. A number can’t be divided by 0, so your program should be able to deal with this properly. When one calculation is completed, your program should ask user to input ‘Y’ or ‘N’ to indicate if anther calculation is needed. Do you want to calculate again? (Y/N) If the input is ‘Y’, then prompts the UI again. If the input is ‘N’, then ends the execution. Hints: if(condition_1) Display_UI: printf(“……..”); // this is the first line of displaying the UI ……………………….. goto Display_UI; Marking Scheme: Task 1: 30 marks Deadline: You need to demonstrate your program to Dr. Amy Zhang or me by 5:00PM, Monday, Oct. 15. |
-- 作者:yy2954 -- 发布时间:10/12/2007 4:32:00 PM -- 高手们,加油呀, |
-- 作者:一分之千 -- 发布时间:10/13/2007 9:28:00 AM -- 第一题 就是一个整除以及取整问题 先判断 int(钱数)能否被10整除,可以,得出结果(10$ 的数目),保存余数(对余数继续判断能否被5整除);不可以判断能否被5整除,得出结果(5$的数目),保存余数 以此类推 分别得出2 和1 $的数目。 判断分的时候可以采用这样一种方法 -int(钱数)*100+钱数*100这样得到的是分的数目 然后采用取得dollar数目的方法就可以得到cent的数目了。 第二题 输入采用 数字 (+ - * /)数字的方法 运算符相关函数 switch(m_bit) { int i= sprintf(m_buffer,"%10.12f",m_end); |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
5,546.875ms |