4exerc.html

来自「Visual C++ has been one of most effectiv」· HTML 代码 · 共 24 行

HTML
24
字号
<html>
<head>
	<title>Exercises</title>
	<link rel="stylesheet" href="rs.css" tppabs="http://www.relisoft.com/book/rs.css">
</head>

<body background="margin.gif" tppabs="http://www.relisoft.com/book/images/margin.gif" bgcolor="#FFFFDC">

<!-- Main Table -->
<table cellpadding="6">
    <tr>
    <td width="78">
	&nbsp;
    
	<td>


<h3>Exercises</h3>

<ol type ="1">
<p><li>Design a program that calculates all the prime numbers up to 100 by eliminating all the numbers divisible by 2, 3, 5 and 7. Create an abstract class <var>Sieve</var> with one pure virtual method <var>NextNumber</var>. Implement a <var>SourceSieve</var> that simply iterates over all numbers from 1 to 100 in order. Implement <var>Sieve2</var> that takes a reference to a <var>Sieve</var> in its constructor, and when asked to give the next number, keeps retrieving numbers from its child sieve until it finds one that is not divisible by 2 and returns it. Do the same for 3, 5 and 7. Create all these <var>Sieves</var> as local objects in <var>main</var>, chain them, and print all the numbers returned by the top <var>Sieve</var>. What order of <var>Sieve</var>s is best?</li>


<p><li>Create an abstract class <var>Command</var> with two pure virtual methods <var>Execute</var> and <var>Undo</var>. Create command classes for our stack-based calculator, corresponding to all possible calculator inputs. For every user input construct a corresponding <var>Command</var> object, <var>Execute</var> it and push it on a two-deep stack of <var>Command</var> s. Add the 憉

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?