本文实例为大家分享了C编写送给女朋友的小程序,供大家参考,具体内容如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
#include<iostream> #include<conio.h> #include<windows.h> #include<time.h> #include<stdio.h> using namespace std; #define wide 49 #define gao 24 #define high 6 int yanhua[gao][wide],hang,lie,i,j,temp,pc,flag; char ch; ////////////////////////////上升函数 void SS() { void printchar(); int midw1,midw,midw2; srand (( int ) time (NULL)); for (hang=gao;hang>=high;hang--) //上升阶段 { midw=wide/2+pc*2; midw1=wide-pc*6; midw2=wide/2-pc*6; yanhua[gao][midw]=10; yanhua[gao][midw1]=10; yanhua[gao][midw2]=10; system ( "cls" ); //清理屏幕 printchar(); if (hang<gao) { int temp; for (temp=gao;temp>hang;temp--) { if (temp<=hang+5) { yanhua[temp][midw]=20; //产生尾巴 yanhua[temp][midw1]=20; yanhua[temp][midw2]=20; } else { yanhua[temp][midw]=0; //清除尾巴 yanhua[temp][midw1]=0; yanhua[temp][midw2]=0; } } yanhua[hang+1][midw]=10; //重设烟花头 yanhua[hang+1][midw1]=10; yanhua[hang+1][midw2]=10; } if (hang==5) { int temp; for (temp=gao;temp>hang;temp--)yanhua[temp][midw]=0; yanhua[hang+1][midw]=10; } Sleep(10); } } ///////////////////////////////爆炸函数 void BZ() { void printchar(); void randnum(); for (temp=1;temp<=3;temp++) { randnum(); system ( "cls" ); printchar(); Sleep(30); } for (i=0;i<gao;i++) { for (j=0;j<wide;j++)yanhua[i][j]=0; } } //////////////////////////////产生随机数函数 void randnum() { srand (( int ) time (0)); for (hang=0;hang<gao;hang++) { for (lie=0;lie<wide;lie++) { yanhua[hang][lie]=( int )((10* rand ())/RAND_MAX); } } } ///////////////////////////////输出图形函数 void printchar() { for (i=0;i<gao;i++) { for (j=0;j<wide;j++) { if (yanhua[i][j]==0)cout<< " " ; else if (yanhua[i][j]==10)cout<< "●" ; else if (yanhua[i][j]==20)cout<< "‖" ; else if (yanhua[i][j]==1)cout<< "*" ; else if (yanhua[i][j]==2)cout<< "·" ; else cout<< " " ; } //输出烟花 cout<<endl; } } ////////////////////////倒计时函数 void djs() { cout<< "精彩不容错过……" ; Sleep(1000); system ( "cls" ); void printchar(); for (temp=3;temp>=1;temp--) { switch (temp) { case 1: for (i=2;i<=15;i++) { for (j=wide/2;j<=wide/2+1;j++)yanhua[i][j]=1; } break ; case 2: for (i=2;i<=15;i++) { switch (i) { case 2: case 3: case 8: case 9: case 14: case 15: for (j=wide/2-7;j<=wide/2+8;j++)yanhua[i][j]=1; break ; case 4: case 5: case 6: case 7: for (j=wide/2+7;j<=wide/2+8;j++)yanhua[i][j]=1; break ; default : for (j=wide/2-7;j<=wide/2-6;j++)yanhua[i][j]=1; break ; } } break ; case 3: for (i=2;i<=15;i++) { switch (i) { case 2: case 3: case 8: case 9: case 14: case 15: for (j=wide/2-7;j<=wide/2+8;j++)yanhua[i][j]=1; break ; default : for (j=wide/2+7;j<=wide/2+8;j++)yanhua[i][j]=1; break ; } } break ; } printchar(); Sleep(1000); for (i=0;i<gao;i++) { for (j=0;j<wide;j++)yanhua[i][j]=0; } system ( "cls" ); } cout<< "烟花开始" ; Sleep(500); } /////////////////////////流星雨 void lxy() { int flag,n; srand (( int ) time (0)); for (hang=0;hang<gao;hang++) { for (lie=0;lie<wide;lie++) { yanhua[hang][lie]=( int )((100* rand ())/RAND_MAX); } } for (flag=0;flag<=4;flag++) { for (temp=1;temp<wide;temp++) { for (i=0,n=0;i<gao;i++) { for (j=wide-1;j>=0;j--) { switch (yanhua[i][j]) { case 56: { cout<< "★" ; n++; if (n%6==0) { yanhua[i-2][j-1]=56; yanhua[i][j]=0; } else { yanhua[i][j+i]=56; yanhua[i][j]=0; } Sleep(0); } break ; case 0: { cout<< "--" ; yanhua[i][j]=1; } break ; default :cout<< " " ; } } } system ( "cls" ); } Sleep(100); } } //////////////////////////////输出文字 void printword() { char ch; cout<<endl; char Word1[80]= "送你一只小熊维尼,让它每天陪着你,和你分享他的蜂蜜,一直甜到你的心里。" ; for (i=0;Word1[i]!=NULL;i++) { cout<<Word1[i]; Sleep(50); } cout<<endl; cout<< "┴┬┴┬/ ̄\_/ ̄\" <<endl; cout<< "┬┴┬┴▏ ▏▔▔▔▔\ " <<endl; cout<< "┴┬┴/\ / ﹨ " <<endl; cout<< "┬┴∕ / ) " <<endl; cout<< "┴┬▏ ● ▏ " <<endl; cout<< "┬┴▏ ▔█ " <<endl; cout<< "┴◢██◣ \___/ " <<endl; cout<< "┬█████◣ / " <<endl; cout<< "┴█████████████◣ " <<endl; cout<< "◢██████████████▆▄ " <<endl; cout<< "█◤◢██◣◥█████████◤\ " <<endl; cout<< "◥◢████ ████████◤ \ " <<endl; cout<< "┴█████ ██████◤ ﹨ " <<endl; cout<< "┬│ │█████◤ ▏ " <<endl; cout<< "┴│ │ ▏ " <<endl; cout<< "┬ ∕ ∕ /▔▔▔\ ∕ " <<endl; cout<< "┴/___/﹨ ∕ ﹨ /\ " <<endl; cout<< "┬┴┬┴┬┴\ \ ﹨/ ﹨ " <<endl; cout<< "┴┬┴┬┴┬┴ \___\ ﹨/▔\﹨ ▔\ " <<endl; cout<< "▲△▲▲╓╥╥╥╥╥╥╥╥\ ∕ /▔﹨/▔﹨ " <<endl; cout<< " **╠╬╬╬╬╬╬╬╬*﹨ / // " <<endl; } ///////////////////////////主函数 int main() { system ( "color 0f" ); djs(); /////////////////////////倒计时 for (pc=1;pc<=10;pc++) ///////////////放烟花 { SS(); switch (pc) { case 1: case 6: system ( "color 8f" ); break ; case 2: case 9: system ( "color 81" ); break ; case 3: case 7: system ( "color 89" ); break ; case 4: case 10: system ( "color 8a" ); break ; case 5: case 8: system ( "color 85" ); break ; } BZ(); system ( "cls" ); system ( "color 0f" ); } char Word2[150]= " 丫头,看完了烟花,我们来看下流星雨吧!现实中流星雨不常见,现在,就让\n我为你制造一场流星雨!可以借机许个愿望哦!\n" ; for (i=0;Word2[i]!=NULL;i++) { cout<<Word2[i]; Sleep(50); } lxy(); char Word3[100]= " 流星雨做的不是很好,但是我也借着这场流星雨许了一个愿望!你呢?\n" ; for (i=0;Word3[i]!=NULL;i++) { cout<<Word3[i]; Sleep(50); } printword(); cout<< "丫头,要开心哦" ; for (flag;flag<=1;flag++)ch= getchar (); exit (0); return 0; } |
由于当时自学了2周的C,代码结构和编程风格都有很大的不足,以后会慢慢发布改进过的代码。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/jickjack/article/details/17845107