上机题目

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
• 提示:使用Exercise 2中设计的StackOfIntegers类来实现
• 写一个程序,接收一个正整数,用户输入 ,并显示所有的最小的因素,在减少秩序 。例如,如果整数是120,最小的因子则显 示为5,3,2,2,2。
上机练习中包含的所有程序代码 以一个压缩文件形式作为邮件附 件发送到: teacherhupo@163.com 邮件标题:学号_姓名_C++上机3 压缩文件命名:学号姓名.rar
本次提交截止时间:10月27日晚21:40
• 栈是一种数据结构,在最后一个数据结构 中,第一种方式将数据存储在一个数据结 构中。请编写一个程序来实现整数的栈, 并测试它。
Exercise 3
• Write a program that receives a positive integer that a user inputs and displays all its smallest factors in decreasing order. For example, if the integer is 120, the smallest factors are displayed as 5, 3, 2 ,2 ,2.
Exe源自文库cise 2
• A stack is a data structure that holds data in a last-in, first-out fashion. Please write a program to implement the stack of integers and test it.
Exercise 1
• Design a class named MyInteger. The class contains the following: • An int data field named value that stores the int value represented by this object. • A constructor that creates a MyInteger object for the specified int value. • A constant get function that return the int value. • Constant functions isEven(), isOdd(), isPrime() that return true if the value is even, odd, or prime, respectively • Static functions isEven(int), isOdd(int), isPrime(int) that return true if the specified value is even, odd, or prime, respectively. • Static functions isEven(const MyInteger&), isOdd(const Myinteger&), isPrime(const MyInteger&) that returns true I f the specified value is even, odd, or prime, respectively. • Constant functions equals(int) and equals(const MyInteger&) that return true if the value in the object is equal to the specified value. • A static function parseInt(const string&) that converts a string to an int value. • Implement the class and write a program to test all functions in the class.
设计一个名为myinteger。该类包含以下: int数据字段指定的值存储该对象表示的int值。 一个构造函数,创建指定的int值myinteger 对象。 一个常数函数返回int值。 常数函数iseven(),isodd(),isprime(),返 回true,如果值是偶数,奇数,或总理,分 别 静态函数是(int),没有提供(int), isPrime(int),返回true,如果指定的值是 偶数,奇数,或总理,分别。静态函数是 (const myinteger &),没有提供(const myinteger &),isPrime(const myinteger &),返回true,如果指定的值是偶数,奇 数,或总理,分别。 常数函数等于(int)和等于(const myinteger &),返回true,如果对象中的值 等于指定值。 静态函数parseInt(const string&),将字 符串转换为一个int值。实现类,编写一个程 序来测试类中的所有函数。
相关文档
最新文档