Normal quotes
This commit is contained in:
parent
5e10794a24
commit
18011c595a
352 changed files with 6040 additions and 6040 deletions
58
15-04.md
58
15-04.md
|
|
@ -72,7 +72,7 @@
|
|||
#include <conio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include “llist.h”
|
||||
#include "llist.h"
|
||||
|
||||
void main()
|
||||
{ int Done = 0, Char, TempValue;
|
||||
|
|
@ -80,60 +80,60 @@
|
|||
char TempBuffer[MAX_TEXT_LENGTH+3];
|
||||
|
||||
if ((ListPtr = InitLinkedList()) == NULL) {
|
||||
printf(“Out of memory\n”);
|
||||
printf("Out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
while (!Done) {
|
||||
printf(“\nA=add; D=delete; F=find; L=list all; Q=quit\n>”);
|
||||
printf("\nA=add; D=delete; F=find; L=list all; Q=quit\n>");
|
||||
Char = toupper(getche());
|
||||
printf(“\n”);
|
||||
printf("\n");
|
||||
switch (Char) {
|
||||
case 'A': /* add a node */
|
||||
if ((TempPtr = malloc(sizeof(struct LinkNode))) == NULL)
|
||||
{
|
||||
printf(“Out of memory\n );
|
||||
printf("Out of memory\n );
|
||||
exit(1);
|
||||
}
|
||||
printf(“Node value: ”);
|
||||
scanf(“%d”, &TempPtr->Value);
|
||||
printf("Node value: ");
|
||||
scanf("%d", &TempPtr->Value);
|
||||
if ((FindNodeBeforeValue(ListPtr,TempPtr->Value))!=NULL)
|
||||
{ printf(“*** value already in list; try again ***\n”);
|
||||
{ printf("*** value already in list; try again ***\n");
|
||||
free(TempPtr);
|
||||
} else {printf(“Node text: ”);
|
||||
} else {printf("Node text: ");
|
||||
TempBuffer[0] = MAX_TEXT_LENGTH;
|
||||
cgets(TempBuffer);
|
||||
strcpy(TempPtr->Text, &TempBuffer[2]);
|
||||
InsertNodeSorted(ListPtr, TempPtr);
|
||||
printf(“\n”);
|
||||
printf("\n");
|
||||
}
|
||||
break;
|
||||
case 'D': /* delete a node */
|
||||
printf(“Value field of node to delete: ”);
|
||||
scanf(“%d”, &TempValue);
|
||||
printf("Value field of node to delete: ");
|
||||
scanf("%d", &TempValue);
|
||||
if ((TempPtr = FindNodeBeforeValue(ListPtr, TempValue))
|
||||
!= NULL) {
|
||||
TempPtr2 = TempPtr->NextNode; /* -> node to delete */
|
||||
DeleteNodeAfter(TempPtr); /* delete it */
|
||||
free(TempPtr2); /* free its memory */
|
||||
} else {
|
||||
printf(“*** no such value field in list ***\n”)
|
||||
printf("*** no such value field in list ***\n")
|
||||
break;
|
||||
case 'F': /* find a node */
|
||||
printf(“Value field of node to find: ”);
|
||||
scanf(“%d”, &TempValue);
|
||||
printf("Value field of node to find: ");
|
||||
scanf("%d", &TempValue);
|
||||
if ((TempPtr = FindNodeBeforeValue(ListPtr, TempValue))
|
||||
!= NULL)
|
||||
printf(“Value: %d\nText: %s\n”,
|
||||
printf("Value: %d\nText: %s\n",
|
||||
TempPtr->NextNode->Value, TempPtr->NextNode->Text);
|
||||
else
|
||||
printf(“*** no such value field in list ***\n”);
|
||||
printf("*** no such value field in list ***\n");
|
||||
break;
|
||||
case 'L': /* list all nodes */
|
||||
TempPtr = ListPtr->NextNode; /* point to first node */
|
||||
if (TempPtr == ListPtr) { /* empty if at sentinel */
|
||||
printf(“*** List is empty ***\n”);
|
||||
printf("*** List is empty ***\n");
|
||||
} else {
|
||||
do {printf(“Value: %d\n Text: %s\n”, TempPtr->Value,
|
||||
do {printf("Value: %d\n Text: %s\n", TempPtr->Value,
|
||||
TempPtr->Text);
|
||||
TempPtr = TempPtr->NextNode;
|
||||
} while (TempPtr != ListPtr);
|
||||
|
|
@ -150,8 +150,8 @@
|
|||
|
||||
### Hi/Lo in 24 Bytes {#Heading6}
|
||||
|
||||
In one of my *PC TECHNIQUES* “Pushing the Envelope” columns, I passed
|
||||
along one of David Stafford’s fiendish programming puzzles: Write a
|
||||
In one of my *PC TECHNIQUES* "Pushing the Envelope" columns, I passed
|
||||
along one of David Stafford's fiendish programming puzzles: Write a
|
||||
C-callable function to find the greatest or smallest unsigned **int**.
|
||||
Not a big deal—except that David had *already* done it in 24 bytes, so
|
||||
the challenge was to do it in 24 bytes or less.
|
||||
|
|
@ -160,16 +160,16 @@ Such routines soon began coming at me from all angles. However (and I
|
|||
hate to say this because some of my correspondents were *very* pleased
|
||||
with the thought that they had bested David), no one has yet met the
|
||||
challenge—because most of you folks missed a key point. When David said,
|
||||
“Write a function to find the greatest or smallest unsigned **int** in
|
||||
24 bytes or less,” he meant, “Write the **hi** and the **lo** functions
|
||||
in 24 bytes or less—*combined*.”
|
||||
"Write a function to find the greatest or smallest unsigned **int** in
|
||||
24 bytes or less," he meant, "Write the **hi** and the **lo** functions
|
||||
in 24 bytes or less—*combined*."
|
||||
|
||||
Oh.
|
||||
|
||||
Yes, a 24-byte hi/lo function is possible, anatomically improbable as it
|
||||
might seem. Which I guess goes to show that when one of David’s puzzles
|
||||
seems less than impossible, odds are you’re missing something. Listing
|
||||
15.9 is David’s 24-byte solution, from which a lot may be learned if one
|
||||
might seem. Which I guess goes to show that when one of David's puzzles
|
||||
seems less than impossible, odds are you're missing something. Listing
|
||||
15.9 is David's 24-byte solution, from which a lot may be learned if one
|
||||
reads closely enough.
|
||||
|
||||
**LISTING 15.9 L15-9.ASM**
|
||||
|
|
@ -203,9 +203,9 @@ reads closely enough.
|
|||
ret
|
||||
|
||||
Before I end this chapter, let me say that I get a lot of feedback from
|
||||
my readers, and it’s much appreciated. Keep those cards, letters, and
|
||||
my readers, and it's much appreciated. Keep those cards, letters, and
|
||||
email messages coming. And if any of you know Jeannie Schweigert, have
|
||||
her drop me a line and let me know how she’s doing these days....
|
||||
her drop me a line and let me know how she's doing these days....
|
||||
|
||||
------------------------ --------------------------------- --------------------
|
||||
[Previous](15-03.html) [Table of Contents](index.html) [Next](16-01.html)
|
||||
|
|
|
|||
Loading…
Reference in a new issue