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

📄 http:^^www.cs.wisc.edu^~milo^cs302^quiz3.html

📁 This data set contains WWW-pages collected from computer science departments of various universities
💻 HTML
字号:
Date: Mon, 11 Nov 1996 17:12:21 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Sat, 02 Nov 1996 21:55:40 GMTContent-length: 2139<HTML><HEAD><TITLE>Quiz 3 - CS 302 Fall 1996 - Section 4</TITLE></HEAD><BODY><H5 ALIGN=RIGHT>Name: _______________________________ </H5><H4 ALIGN=CENTER>  <!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><A HREF="http://www.cs.wisc.edu/~cs302">CS 302</A>  Fall 1996 - <!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><A HREF="http://www.cs.wisc.edu/~milo/cs302.html">Section 4</A></H4> <H4 ALIGN=CENTER>Quiz 3</H4><H5 ALIGN=CENTER>Monday, October 28, 1996</H5> <hr><br>This quiz is 20 total points.  Please write legibly.  If I can't readit, I can't grade it.  You have until 5 minutes after the class periodends to finish.Good luck.<OL>  <LI> (5 points) Write the <TT>struct</TT> declaration for astructure called ``Computer'' which has four member variables: aninteger <TT>disk_size</TT>, an integer <TT>monitor_size</TT>, acharacter <TT>model_type</TT>, and a double <TT>total_price</TT>.        <br> <br> <br> <br> <br> <br>        <br> <br>   <LI> (5 points) Rewrite the following function to use switch statementinstead of a nested if-else statement.  Your code should have no ifstatements.<PRE>int foo(int number, int value) {  if (number == 1) {    value = value * 2;  } else if (number == 3) {    value = value + 10;  } else if ((number == 4) || (number == 6)) {    value = value * value;  } else {    value = 17;  }  return value;}</PRE>        <br> <br> <br> <br> <br> <br>        <br> <br>         <br> <br> <H5 ALIGN=CENTER>- Over - </H5>  <LI> (5 points) What does the following code display to the screen?<PRE>#include&ltiostream.h&gtint bar(int number, int value) {  if ((number == 1) && (value++ > 0)) {    return value + 10;  } else {    return value;  }}int main() {  cout << bar(0, 0) << endl;  cout << bar(1, 0) << endl;  cout << bar(0, 1) << endl;  cout << bar(1, 1) << endl;}</PRE>        <br> <br>         <br> <br>   <LI> (5 points) Rewrite the following function to use a while ordo-while loop instead of a for loop.<PRE>int factorial(int n) {  int counter, fact = 1;  for(counter = 1; counter <= n; counter++) {    fact *= counter;  }  return fact;}</PRE><br> <br> <br> <br> <br> <br></OL></BODY></HTML>

⌨️ 快捷键说明

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