`

SSD06 Practical Quiz 1 个人解答

阅读更多

这个题目和Exercise02 没什么区别,在这里把我的解答给出来,就不再赘述了。

Introduction

The purpose of this assignment is to become more familiar with bit-level representations and manipulations. As with the Data Lab, you'll do this by solving a small number of programming "puzzles."

Getting Started

Download and unzip dlabp-handout.zip to a directory in which you plan to do your work. This will cause the following files to be unpacked into the directory:

bits.c The data puzzles that you will solve. This is the file you will be modifying and handing in.
dlabp.vcproj
Project file
README Helpful information about the lab
btest.c
btest.h
decl.c
test.c
getopt.c
bits.h
getopt.h
tailor.h
The test driver and its helper files

Open the dlabp.vcproj workspace from VC++ and you are ready to begin solving your puzzles. You can add this project to a pre-existing (or new) VC++.Net Solution

Your Task

The only file you will be modifying and turning in is bits.c . Looking at bits.c you'll notice a C structure called info into which you should insert your name and login ID. Do this right away so you don't forget, as the driver will not run without it.

The bits.c file also contains a skeleton for each of the 4 programming puzzles. As before, your assignment is to complete each function skeleton using only straightline code (i.e., no loops or conditionals) and a limited number of C arithmetic and logical operators. Specifically, you are only allowed to use the following eight operators:

 ! ~ & ^ | + << >>

A few of the functions further restrict this list. See the comments in bits.c for detailed rules and a discussion of the desired coding style.

The enclosed dlabp.vcproj project will help you compile your bits.c file, along with the other helper functions, and link them all together to form the executable driver program btest.exe . The btest.exe driver program allows you to evaluate the functional correctness of your code. Every time you modify one of the puzzles in bits.c , you can check its correctness by rebuilding and rerunning btest.exe .

Puzzles

The following table describes the 4 puzzles that you will be solving in bits.c . The ``Rating'' field gives the difficulty rating (the number of points) for the puzzle, and the ``Max ops'' field gives the maximum number of operators you are allowed to use to implement each function.

Name Description Rating Max Ops
tmin() Returns the minimum two's complement integer 1 4
minusFive() Returns the integer value -5 1 4
copyLSB(x) Sets all bits of result to least significant bit of x 2 5
getBit(x, n) Extract bit n from word x 2 4

See the bits.c file for examples of the results returned by these functions.

Evaluation

Your score will be computed out of a maximum of 12 points based on the following distribution:

6 Correctness of code as reported by btest.exe
(no credit for a puzzle if your instructor determines that you have used an illegal operator).
4 Performance of code, based on number of operators used in each function (maximum of 1 point per puzzle).
2 Style points, based on your instructor's subjective evaluation of the quality of your solutions and your comments.

The puzzles you must solve have been given a difficulty rating between 1 and 2, such that their weighted sum totals to 6. Your instructor will evaluate your functions using the same btest.exe driver that you are using. You will get full credit for a puzzle if it passes all of the tests performed by btest.exe , half credit if it fails one test, and no credit otherwise. You receive no credit if you use an illegal operator for your solution, so pay close attention to the list of allowed operators for each puzzle in bits.c .

As before, we've established a maximum number of operators that you are allowed to use for each function. You will receive one point for each function that satisfies the operator limit.

Finally, we've reserved two points for a subjective evaluation of the style of your solutions and your commenting. Your solutions should be as clean and straightforward as possible. Your comments should be informative, but they need not be extensive.

Advice

  • Read the file README for information on running the btest.exe program.
  • You'll find it helpful to work through the functions one at a time, testing each one as you go. You can use the -f flag to instruct btest.exe to test only a single function. For example, "btest.exe -f bitAnd ".
  • The "-g " flag is very handy for producing a concise summary of your correctness results. For example, "btest -g ".
  • btest.exe is a console application, so you'll need to run it from the Windows command line. On a Windows 2000 system, you can find this at "Start->Accessories->Command Prompt". If you try to run it using "Start->Run.." instead, you won't see any of the output.

Hand In Instructions

Before submitting your solution:

  • Make sure you have included your identifying information in your file bits.c .
  • Remove any extraneous print statements that you might have included for debugging.
  • bits.c.zip (1.8 KB)
  • 描述: 我的解答,没做测试
  • 下载次数: 34
分享到:
评论

相关推荐

    SSD06 Practical Quiz 2 个人解答

    【SSD06 实践小测 2 个人解答】主要涵盖了两个关键知识点:源码分析和工具使用。在这个实践小测中,作者通过撰写博客(博文链接:https://qianjigui.iteye.com/blog/282718)分享了解答过程,这些内容可能涉及编程...

    ssd3 practical quiz 6

    ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5

    ssd3 practical quiz 3

    ssd3 practical quiz 3ssd3 practical quiz 3ssd3 practical quiz 3ssd3 practical quiz 3ssd3 practical quiz 3ssd3 practical quiz 3ssd3 practical quiz 3

    ssd3 practical quiz 8

    ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8ssd3 practical quiz 8

    ssd3 Practical Quiz 7 答案

    SSD3,全称为“Solid State Drives 3”,通常是指...以上就是关于SSD3的一些关键知识点,对于解答"Practical Quiz 7"会有很大帮助。了解并掌握这些内容,不仅能够应对考试,还能在实际工作中更好地理解和应用SSD3技术。

    ssd3 practical quiz 1

    ssd3 practical quiz 1ssd3 practical quiz 1ssd3 practical quiz 1ssd3 practical quiz 1ssd3 practical quiz 1 ssd3 practical quiz 1

    SSD04 Practical Quiz 4 个人解答

    【SSD04 实践测试4 个人解答】 在本次实践测试4中,我们主要探讨了与源码理解和工具使用相关的知识。通过个人的解答,我们可以深入理解这些关键概念,并提高在实际开发中的应用能力。以下是对每个部分的详细解析: ...

    ssd3 practical quiz 2

    ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2ssd3 practical quiz 2

    SSD04 Practical Quiz 1 个人解答

    标题"SSD04 Practical Quiz 1 个人解答"指的是一个实践测试,可能来自某个课程或培训计划,编号为SSD04的第1个实践环节。这个测试旨在检验参与者对于特定技术或概念的理解和应用能力。 描述中提到的“我的解答”...

    ssd3 practical quiz2

    【标题】"ssd3 practical quiz2"是一个与软件工程相关的实践测验,可能是课程"Software System Development 3"(SSD3)的一部分。这个测验可能涉及了软件开发过程中的实际操作和问题解决,旨在检验学生在项目管理和...

    ssd3 practical quiz 5

    ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5ssd3 practical quiz 5

    SSD3 Practical Quiz8

    SSD3 Practical Quiz8 2009 StudentArrayList.java

    ssd3 practical quiz6

    "ssd3 practical quiz6"很可能是某个教育课程或培训项目的一部分,旨在测试或提升学员对SSD技术及其应用的理解。 在这个2007年的卡耐基软件工程网络教材中,"ssd3"可能指的是课程的序列号或者级别,暗示这已经是...

    ssd3 practical quiz 7

    这个"practical quiz 7"是该课程中的第七次实践测验,旨在测试学生对SSD3理论知识的理解以及在实际操作中的应用。由于没有提供具体的文件内容,我将根据SSD3可能涵盖的主题来生成相关的知识点。 1. **固态存储基础*...

    ssd3 practical quiz4

    【标题】"ssd3 practical quiz4" 是一个与软件工程相关的实践测验,很可能源自2007年卡耐基梅隆大学的课程。这个测验可能旨在检验学生对软件开发过程、软件设计原则、编程技能以及项目管理的理解。 【描述】提及的...

    ssd3 practical quiz8

    【标题】:“ssd3 practical quiz8”是一个关于软件工程的实践测验,可能是课程“Software System Development 3”的第八次实践考核。这个标题暗示我们将探讨与软件开发过程中的实践问题相关的知识,可能涵盖编程、...

    ssd4 practical Quiz1 PrQ1

    ssd4 practical Quiz1 PrQ1 ssd4 practical Quiz1 PrQ1 ssd4 practical Quiz1 PrQ1 ssd4 practical Quiz1 PrQ1

Global site tag (gtag.js) - Google Analytics