http:^^www.cs.wisc.edu^~burnett^cs302^quizzes^quiz3_sol.html

来自「This data set contains WWW-pages collect」· HTML 代码 · 共 95 行

HTML
95
字号
Date: Mon, 11 Nov 1996 17:40:53 GMTServer: NCSA/1.5Content-type: text/htmlLast-modified: Thu, 31 Oct 1996 22:35:40 GMTContent-length: 1721<html><head><title>Solutions to Quiz Three</title></head><body><h3><center>Solutions to Quiz Three<p><a href="quiz3.html">The quiz itself</a><p></h3><b>Disclaimer</b>: answer key code has <em>not</em> been tested.<p></center><ol> <li> For Loops<pre>	int i, j;	for (i = 9; i >= 1; i--) {	   for (j = i; j <= 9; j++)	      cout << j << ' ';	   cout << endl;	   if (i != 5)	      cout << '*' << end;;	}</pre><li>Working with Structures.<p>	<ul>	<li>Write a definition for a struct <b>ApptPage</b> (appointment page).	Each ApptPage should have a field for the date and a field	for the number of appointments. (<em>3 points</em>)<p><pre>	struct ApptPage {	   Date date;	   int num_appts;	};</pre><p>	<li>Write a code segment that declares an appointment page variable,	sets the date to October 31 and sets the number of appointments to 5.	<p><pre>	ApptPage ap;	ap.date.month = OCT;	ap.date.day = 31;	ap.num_appts = 5;</pre><p><b><em>or</em></b><p><pre>	ApptPage ap = {{OCT, 31}, 5};</pre><p>		<li>Write a function that takes a date and returns a logical	value based on whether that date is valid or not.<p><pre>	int validDate(Date d) {	   int valid;  // 1 if valid, 0 if invalid	   switch (d.month) {	      case JAN:	      case MAR:	      case MAY:	      case JUL:	      case AUG:	      case OCT:	      case DEC:	         valid = (d.day >= 1 && d.day <= 31); break;	      case APR:	      case JUN:	      case SEP:	      case NOV:		 valid = (d.day >= 1 && d.day <= 30); break;	      case FEB: 	         valid = (d.day >= 1 && d.day <= 29); break;	      default:		 valid = 0;   // invalid Month!           }           return (valid);	}</ol>

⌨️ 快捷键说明

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