tricks.ps

来自「c programming pearls answer」· PS 代码 · 共 1,167 行 · 第 1/2 页

PS
1,167
字号
%!PS-Adobe-2.0
%%Copyright: Copyright (c) 1993 AT&T, All Rights Reserved
%%Version: 3.4
%%DocumentFonts: (atend)
%%Pages: (atend)
%%BoundingBox: (atend)
%%EndComments
/DpostDict 200 dict def
DpostDict begin
%
% Copyright (c) 1993 AT&T, All Rights Reserved
%
% Version 3.4 prologue for troff files.
%

/#copies 1 store
/Prologue (dpost.ps) def
/aspectratio 1 def
/formsperpage 1 def
/landscape false def
/linewidth .3 def
/magnification 1 def
/margin 0 def
/orientation 0 def
/resolution 720 def
/rotation 1 def
/xoffset 0 def
/yoffset 0 def

/roundpage true def
/useclippath true def
/pagebbox [0 0 612 792] def

/R  /Times-Roman def
/I  /Times-Italic def
/B  /Times-Bold def
/BI /Times-BoldItalic def
/H  /Helvetica def
/HI /Helvetica-Oblique def
/HB /Helvetica-Bold def
/HX /Helvetica-BoldOblique def
/CW /Courier def
/CO /Courier def
/CI /Courier-Oblique def
/CB /Courier-Bold def
/CX /Courier-BoldOblique def
/PA /Palatino-Roman def
/PI /Palatino-Italic def
/PB /Palatino-Bold def
/PX /Palatino-BoldItalic def
/Hr /Helvetica-Narrow def
/Hi /Helvetica-Narrow-Oblique def
/Hb /Helvetica-Narrow-Bold def
/Hx /Helvetica-Narrow-BoldOblique def
/KR /Bookman-Light def
/KI /Bookman-LightItalic def
/KB /Bookman-Demi def
/KX /Bookman-DemiItalic def
/AR /AvantGarde-Book def
/AI /AvantGarde-BookOblique def
/AB /AvantGarde-Demi def
/AX /AvantGarde-DemiOblique def
/NR /NewCenturySchlbk-Roman def
/NI /NewCenturySchlbk-Italic def
/NB /NewCenturySchlbk-Bold def
/NX /NewCenturySchlbk-BoldItalic def
/ZD /ZapfDingbats def
/ZI /ZapfChancery-MediumItalic def
/S  /S def
/S1 /S1 def
/GR /Symbol def

/inch {72 mul} bind def
/min {2 copy gt {exch} if pop} bind def

/setup {
	counttomark 2 idiv {def} repeat pop

	landscape {/orientation 90 orientation add def} if
	/scaling 72 resolution div def
	linewidth setlinewidth
	1 setlinecap

	pagedimensions
	xcenter ycenter translate
	orientation rotation mul rotate
	width 2 div neg height 2 div translate
	xoffset inch yoffset inch neg translate
	margin 2 div dup neg translate
	magnification dup aspectratio mul scale
	scaling scaling scale

	addmetrics
	0 0 moveto
} def

/pagedimensions {
	useclippath userdict /gotpagebbox known not and {
		/pagebbox [clippath pathbbox newpath] def
		roundpage currentdict /roundpagebbox known and {roundpagebbox} if
	} if
	pagebbox aload pop
	4 -1 roll exch 4 1 roll 4 copy
	landscape {4 2 roll} if
	sub /width exch def
	sub /height exch def
	add 2 div /xcenter exch def
	add 2 div /ycenter exch def
	userdict /gotpagebbox true put
} def

/landscapepage {
	landscape not {
		0 height scaling div neg translate	% not quite
		90 rotate
	} if
} bind def

/portraitpage {
	landscape {
		width scaling div 0 translate	% not quite
		-90 rotate
	} if
} bind def

/addmetrics {
	/Symbol /S null Sdefs cf
	/Times-Roman /S1 StandardEncoding dup length array copy S1defs cf
} def

/pagesetup {
	/page exch def
	currentdict /pagedict known currentdict page known and {
		page load pagedict exch get cvx exec
	} if
} def

/decodingdefs [
	{counttomark 2 idiv {y moveto show} repeat}
	{neg /y exch def counttomark 2 idiv {y moveto show} repeat}
	{neg moveto {2 index stringwidth pop sub exch div 0 32 4 -1 roll widthshow} repeat}
	{neg moveto {spacewidth sub 0.0 32 4 -1 roll widthshow} repeat}
	{counttomark 2 idiv {y moveto show} repeat}
	{neg setfunnytext}
] def

/setdecoding {/t decodingdefs 3 -1 roll get bind def} bind def

/w {neg moveto show} bind def
/m {neg dup /y exch def moveto} bind def
/done {/lastpage where {pop lastpage} if} def

/f {
	dup /font exch def findfont exch
	dup /ptsize exch def scaling div dup /size exch def scalefont setfont
	linewidth ptsize mul scaling 10 mul div setlinewidth
	/spacewidth ( ) stringwidth pop def
} bind def

/changefont {
	/fontheight exch def
	/fontslant exch def
	currentfont [
		1 0
		fontheight ptsize div fontslant sin mul fontslant cos div
		fontheight ptsize div
		0 0
	] makefont setfont
} bind def

/sf {f} bind def

/cf {
	dup length 2 idiv
	/entries exch def
	/chtab exch def
	/newencoding exch def
	/newfont exch def

	findfont dup length 1 add dict
	/newdict exch def
	{1 index /FID ne {newdict 3 1 roll put}{pop pop} ifelse} forall

	newencoding type /arraytype eq {newdict /Encoding newencoding put} if

	newdict /Metrics entries dict put
	newdict /Metrics get
	begin
		chtab aload pop
		1 1 entries {pop def} for
		newfont newdict definefont pop
	end
} bind def

%
% A few arrays used to adjust reference points and character widths in some
% of the printer resident fonts. If square roots are too high try changing
% the lines describing /radical and /radicalex to,
%
%	/radical	[0 -75 550 0]
%	/radicalex	[-50 -75 500 0]
%
% Move braceleftbt a bit - default PostScript character is off a bit.
%

/Sdefs [
	/bracketlefttp		[201 500]
	/bracketleftbt		[201 500]
	/bracketrighttp		[-81 380]
	/bracketrightbt		[-83 380]
	/braceleftbt		[203 490]
	/bracketrightex		[220 -125 500 0]
	/radical		[0 0 550 0]
	/radicalex		[-50 0 500 0]
	/parenleftex		[-20 -170 0 0]
	/integral		[100 -50 500 0]
	/infinity		[10 -75 730 0]
] def

/S1defs [
	/underscore		[0 80 500 0]
	/endash			[7 90 650 0]
] def
end
%%EndProlog
%%BeginSetup
DpostDict begin
mark
/rotation 1 def
/gotpagebbox true def
/linewidth 0.5 def
/xoffset 0 def
/yoffset 0 def
/#copies 1 store
/magnification 1 def
%%FormsPerPage: 1
/formsperpage 1 def
%%Patch from lp
%%EndPatch from lp
/landscape false def
/resolution 720 def
setup
2 setdecoding
%
% Copyright (c) 1993 AT&T, All Rights Reserved
%
% Version 3.4 drawing procedures for dpost. Automatically pulled in when
% needed.
%

/inpath false def
/savematrix matrix def

/Dl {
	inpath
		{pop pop neg lineto}
		{newpath neg moveto neg lineto stroke}
	ifelse
} bind def

/De {
	/y1 exch 2 div def
	/x1 exch 2 div def
	/savematrix savematrix currentmatrix def
	neg exch x1 add exch translate
	x1 y1 scale
	0 0 1 0 360
	inpath
		{1 0 moveto arc savematrix setmatrix}
		{newpath arc savematrix setmatrix stroke}
	ifelse
} bind def

/Da {
	/dy2 exch def
	/dx2 exch def
	/dy1 exch def
	/dx1 exch def
	dy1 add neg exch dx1 add exch
	dx1 dx1 mul dy1 dy1 mul add sqrt
	dy1 dx1 neg atan
	dy2 neg dx2 atan
	inpath
		{arc}
		{newpath arc stroke}
	ifelse
} bind def

/DA {
	/dy2 exch def
	/dx2 exch def
	/dy1 exch def
	/dx1 exch def
	dy1 add neg exch dx1 add exch
	dx1 dx1 mul dy1 dy1 mul add sqrt
	dy1 dx1 neg atan
	dy2 neg dx2 atan
	inpath
		{arcn}
		{newpath arcn stroke}
	ifelse
} bind def

/Ds {
	/y2 exch def
	/x2 exch def
	/y1 exch def
	/x1 exch def
	/y0 exch def
	/x0 exch def
	x0 5 x1 mul add 6 div
	y0 5 y1 mul add -6 div
	x2 5 x1 mul add 6 div
	y2 5 y1 mul add -6 div
	x1 x2 add 2 div
	y1 y2 add -2 div
	inpath
		{curveto}
		{newpath x0 x1 add 2 div y0 y1 add -2 div moveto curveto stroke}
	ifelse
} bind def
end
%%EndSetup
%%Page: 1 1
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
1 pagesetup
20 H f
(Tricks of the Programming Trade)4 2930 1 1415 960 t
(Jon Bentley)1 1050 1 3080 2052 t
(Bell Labs)1 826 1 3080 2292 t
(Problem Definition)1 1638 1 1080 3372 t
(The Back of the Envelope)4 2302 1 1080 3612 t
(Debugging)1080 3852 w
(Other Tricks)1 1090 1 1080 4092 t
20 CW f
(www.programmingpearls.com/tricks)1296 5167 w
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-2000-1)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 1 1
%%Page: 2 2
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
2 pagesetup
20 H f
(Three Kinds of Knowledge)3 2356 1 1882 960 t
(General)720 1560 w
(1. Science)1 938 1 1008 2040 t
(2. Project Management)2 2076 1 1008 2520 t
(3. ``Tricks of the Trade'')4 2072 1 1008 3000 t
(Examples from Medicine)2 2194 1 720 3480 t
(1. Chemistry, Biology)2 1894 1 1008 3960 t
(2. Operating teams, Medical records)4 3234 1 1008 4440 t
(3. Blood samples)2 1540 1 1008 4920 t
(Examples from Software)2 2184 1 720 5400 t
(1. Program veri\256cation, algorithm design)4 3590 1 1008 5880 t
(2. Team organization, scheduling)3 2958 1 1008 6360 t
(3. This talk)2 970 1 1008 6840 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-2000-2)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 2 2
%%Page: 3 3
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
3 pagesetup
20 H f
(About This Talk)2 1394 1 2507 960 t
(Goals)720 1560 w
(For the listeners: a few amusing stories, and a)8 4106 1 1008 2040 t
(prod to think about tricks.)4 2244 1 1008 2280 t
(For the talker: more stories and tricks.)6 3366 1 1008 2760 t
(Rules)720 3240 w
(Mandatory: real-time thought, some discussion.)4 4216 1 1008 3720 t
(Illegal: note taking, verbal answers from table-)6 4094 1 1008 4200 t
(lookup.)1008 4440 w
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-2000-3)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 3 3
%%Page: 4 4
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
4 pagesetup
20 H f
(Problem De\256nition)1 1638 1 2385 960 t
(Context)720 1560 w
(A public opinion polling \256rm wishes to draw a)8 3992 1 1008 2040 t
(random sample from a \(hardcopy\) list of pre-)7 3956 1 1008 2280 t
(cincts.)1008 2520 w
(The User's Idea)2 1416 1 720 3000 t
20 HI f
(Input:)1008 3480 w
20 H f
(The user types)2 1328 1 1568 3480 t
20 HI f
(n)2952 3480 w
20 H f
(precinct names \(10-)2 1772 1 3120 3480 t
(character strings\) and an integer)4 2890 1 1008 3720 t
20 HI f
(m)3954 3720 w
20 S f
(<)4169 3720 w
20 HI f
(n)4312 3720 w
20 H f
(. Typi-)1 612 1 4424 3720 t
(cally,)1008 3960 w
20 HI f
(m)1520 3960 w
20 S f
(~)1774 3920 w
(~)1774 3970 w
20 H f
(20 and)1 616 1 1972 3960 t
20 HI f
(n)2644 3960 w
20 S f
(~)2844 3920 w
(~)2844 3970 w
20 H f
(200.)3042 3960 w
20 HI f
(Output:)1008 4440 w
20 H f
(Random selection of)2 1830 1 1724 4440 t
20 HI f
(m)3610 4440 w
20 H f
(names.)3832 4440 w
(A Better Problem)2 1528 1 720 4920 t
20 HI f
(Input:)1008 5400 w
20 H f
(Integers)1568 5400 w
20 HI f
(m)2350 5400 w
20 H f
(and)2572 5400 w
20 HI f
(n)2964 5400 w
20 H f
(.)3076 5400 w
20 HI f
(Output:)1008 5880 w
20 H f
(A sorted list of)3 1272 1 1724 5880 t
20 HI f
(m)3052 5880 w
20 H f
(integers in the range)3 1832 1 3274 5880 t
(1..)1008 6120 w
20 HI f
(n)1232 6120 w
20 H f
( example, if)2 1026(. For)1 468 2 1344 6120 t
20 HI f
(m)2894 6120 w
20 S f
(=)3109 6120 w
20 H f
(3 and)1 504 1 3252 6120 t
20 HI f
(n)3812 6120 w
20 S f
(=)3973 6120 w
20 H f
(8, the output)2 1120 1 4116 6120 t
(might be 2, 3, 5.)4 1442 1 1008 6360 t
(Better Yet)1 894 1 720 6840 t
20 HI f
(Input:)1008 7320 w
20 H f
(A hardcopy list of precincts.)4 2454 1 1568 7320 t
6 H f
(From)720 7800 w
6 I f
(Programming Pearls)1 507 1 878 7800 t
6 R f
(, Copyright)1 274 1 1385 7800 t
6 S f
(\323)1674 7800 w
6 R f
( Pearls-2000-4)1 3011(2000, Lucent Technologies)2 653 2 1736 7800 t
cleartomark
showpage
saveobj restore
end
%%PageBoundingBox: 61 -1 550 726
%%EndPage: 4 4
%%Page: 5 5
%%PageBoundingBox: (atend)
DpostDict begin
/saveobj save def
mark
5 pagesetup
20 H f
(Another Randomizing Problem)2 2732 1 1838 960 t
(The Problem)1 1148 1 720 1560 t
(For)1008 2040 w
20 HI f
(N)1364 2040 w
20 S f
(=)1557 2040 w
20 H f
(72 psychological subjects, randomly per-)4 3624 1 1700 2040 t
(mute order of experimenters \(1, 2, 3\) and stress)8 4250 1 1008 2280 t
(conditions \(High, Medium, Low\).)3 2864 1 1008 2520 t
(Output of the Program)3 1988 1 1008 3000 t
20 CW f
(1 3L 2M 1H)3 1200 1 1584 3295 t
(2 3H 1M 2L)3 1200 1 1584 3530 t
(3 1L 2H 3M)3 1200 1 1584 3765 t
(4 1M 2L 3H)3 1200 1 1584 4000 t
(...)1824 4235 w
20 H f
(A More Elegant Solution)3 2166 1 720 4775 t
14 H f
1800 5555 1800 6275 Dl
2520 5555 1800 5555 Dl
2520 6275 2520 5555 Dl
1800 6275 2520 6275 Dl
2160 5339 1800 5555 Dl
2880 5339 2160 5339 Dl
2880 6059 2880 5339 Dl
2520 6275 2880 6059 Dl
2880 5339 2520 5555 Dl
(123)2043 5943 w
(132)2583 5835 w
(213)2223 5475 w
3240 5555 3240 6275 Dl
3960 5555 3240 5555 Dl
3960 6275 3960 5555 Dl
3240 6275 3960 6275 Dl
3600 5339 3240 5555 Dl
4320 5339 3600 5339 Dl
4320 6059 4320 5339 Dl
3960 6275 4320 6059 Dl

⌨️ 快捷键说明

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