⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 4exerc.html

📁 C ++ in action
💻 HTML
字号:
<html>
<head>
	<title>Exercises</title>
	<link rel="stylesheet" href="../../rs.css">
</head>

<body background="../../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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -