您的位置:首页 > 理论基础 > 数据结构算法

数据结构代码整理(2)

2005-07-31 20:16 429 查看
附:趣味小程序
1) /*fc.c*/
2) # include<graphics.h>
3) # include<stdlib.h>
4) # include<stdio.h>
5) # include<conio.h>
6) # define IMAGE_SIZE 10
7) void draw_image(int x,int y);
8) void Putstar(void);
9) main()
10) {int gdriver=DETECT,gmode,color;
11) void *p;
12) int x,y,maxx,maxy,midy,midx,i;
13) unsigned int size ;
14) initgraph(&gdriver,&gmode,"");
15) maxx=getmaxx();
16) maxy=getmaxy();
17) midx=maxx/2;
18) x=0;
19) midy=y=maxy/2;
20) setcolor(YELLOW);
21) settextstyle(0,0,1);
22) /*settextjustify(CENTER_TEXT,CENTER_TEXT);*/
23) /*outtextxy(midx,400,"ChenLu , You know how I missing you !");*/
24) setbkcolor(BLACK);
25) setcolor(RED);
26) Putstar();
27) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
28) /*draw_image(x,y);*/
29) size=imagesize(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE);
30) p=malloc(size);
31) getimage(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE,p);
32) setcolor(WHITE);
33) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
34) rectangle(0,0,maxx,maxy);
35) setcolor(YELLOW);
36) outtextxy(10,20,"After some time , I finially made up my mind ");
37) delay(18000);
38) outtextxy(10,50,"She is the girl , and I really want to make her mine . ");
39) delay(18000);
40) outtextxy(10,80,"I'm searching everywhere to find her again .");
41) delay(18000);
42) outtextxy(10,110,"To tell her I love her and I'm sorry about the thing I've done .");
43) delay(18000);
44) outtextxy(10,140,"I found her standing in front of the church. ");
45) delay(18000);
46) outtextxy(10,170,"The only place in town where I didn't search . ");
47) delay(18000);
48) outtextxy(10,200,"She looked so happy in the wedding dress ,");
49) delay(28000);
50) outtextxy(10,230,"but she's crying while she say in this:");
51) delay(18000);
52) outtextxy(4,260,""Boy I missed your kissess , all the time , ");
53) delay(18000);
54) outtextxy(4,290,"but this is 25 minutes too late . ");
55) delay(18000);
56) outtextxy(4,320,"Though you travelled so far , boy .");
57) delay(18000);
58) outtextxy(4,350,"I'm sorry you are 25 minutes too late ." ");
59) delay(28000);
60) cleardevice();
61) setbkcolor(BLACK);
62) setcolor(RED);
63) Putstar();
64) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
65) size=imagesize(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE);
66) p=malloc(size);
67) getimage(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE,p);
68) setcolor(WHITE);
69) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
70) rectangle(0,0,maxx,maxy);
71) setcolor(YELLOW);
72) outtextxy(10,50,"Against the wind , I'm going home again ");
73) delay(18000);
74) outtextxy(10,90,"Wishing me back to the time when we were more than friends . ");
75) delay(18000);
76) outtextxy(10,130,"But I still see her standing in front of the church .");
77) delay(18000);
78) outtextxy(10,170,"The only place in town where I didn't search . ");
79) delay(18000);
80) outtextxy(10,210,"She looked so happy in the wedding dress ,");
81) delay(18000);
82) outtextxy(10,250,"but she's crying while she say in this:");
83) delay(18000);
84) outtextxy(4,290,""Boy I missed your kissess , all the time , ");
85) delay(18000);
86) outtextxy(4,330,"but this is 25 minutes too late . ");
87) delay(18000);
88) outtextxy(4,370,"Though you travelled so far , boy .");
89) delay(18000);
90) outtextxy(4,410,"I'm sorry you are 25 minutes too late ." ");
91) delay(28000);
92) cleardevice();
93) setbkcolor(BLACK);
94) setcolor(RED);
95) Putstar();
96) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
97) size=imagesize(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE);
98) p=malloc(size);
99) getimage(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE,p);
100) setcolor(WHITE);
101) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
102) rectangle(0,0,maxx,maxy);
103) setcolor(YELLOW);
104) outtextxy(10,80,"Out in the street , places where hurgry hearts have nothing to eat. ");
105) delay(18000);
106) outtextxy(10,150,"Inside my hand , but still I can hear the words she said: ");
107) delay(18000);
108) outtextxy(4,220,""Boy I missed your kissess , all the time , ");
109) delay(18000);
110) outtextxy(4,290,"but this is 25 minutes too late . ");
111) delay(18000);
112) outtextxy(4,360,"Though you travelled so far , boy .");
113) delay(18000);
114) outtextxy(4,430,"I'm sorry you are 25 minutes too late ." ");
115) delay(28000);
116) cleardevice();
117) setcolor(WHITE);
118) setcolor(YELLOW);
119) settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
120) settextjustify(CENTER_TEXT,CENTER_TEXT);
121) outtextxy(midx,400,"Hello World ");
122) setbkcolor(BLACK);
123) setcolor(RED);
124) Putstar();
125) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
126) draw_image(x,y);
127) size=imagesize(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE);
128) p=malloc(size);
129) getimage(x,y-IMAGE_SIZE,x+(4*IMAGE_SIZE),y+IMAGE_SIZE,p);
130) setcolor(WHITE);
131) setlinestyle(SOLID_LINE,0,NORM_WIDTH);
132) rectangle(0,0,maxx,maxy);
133) setcolor(YELLOW);

134) while(!kbhit())
135) {
136) Putstar();
137) setcolor(RED);
138) setlinestyle(SOLID_LINE,0,THICK_WIDTH);
139) ellipse(midx,midy,130,150,160,30);
140) setcolor(BLACK);
141) ellipse(midx,midy,130,50,160,30);
142) for(i=0;i<13;i++)
143) {
144) setcolor(i%2==0?LIGHTBLUE:BLACK);
145) ellipse(midx,midy,0,360,100,100-8*i);
146) setcolor(LIGHTBLUE);
147) ellipse(midx,midy,0,360,100-8*i,100);
148) }
149) putimage(x,y-IMAGE_SIZE,p,XOR_PUT);
150) x=x>=maxx?0:x+6;
151) putimage(x,y-IMAGE_SIZE,p,XOR_PUT);
152) }
153) free(p);
154) closegraph();
155) return;
156) }

157) void draw_image(int x,int y)
158) {
159) int arw[11];
160) arw[0]=x+10;arw[1]=y-10;arw[2]=x+34;arw[3]=y-6;
161) arw[4]=x+34;arw[5]=y+6;arw[6]=x+10;arw[7]=y+10;
162) arw[8]=x+10;arw[10]=y-10;
163) moveto(x+10,y-4);
164) setcolor(14);
165) setfillstyle(1,4);
166) linerel(-3*10,0);
167) setcolor(3);
168) setfillstyle(1,LIGHTBLUE);
169) fillpoly(4,arw);
170) }

171) void Putstar(void)
172) {
173) int seed=1858;
174) int i,dotx,doty,h,w,color,maxcolor;
175) maxcolor=getmaxcolor();
176) w=getmaxx();
177) h=getmaxy();
178) srand(seed);
179) for(i=0;i<250;i++)
180) {
181) dotx=i+random(w-1);
182) doty=1+random(h-1);
183) color=random(maxcolor);
184) setcolor(color);
185) putpixel(dotx,doty,color);
186) circle(dotx+1,doty+1,1);
187) }
188) srand(seed);
189} }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: