Part of the content comes from the Internet.
If there is any infringement, please let me know and I 'll delete it in time.
This code is creat with the help of the codes from internet.
If you wanna tell a girl something, you understand^_^.
1 #include<bits/stdc++.h> 2 #include<windows.h> 3 //#include<pthread.h> 4 #include<tchar.h> 5 #include<sys/time.h> 6 #define INF 0x3f3f3f3f3f3f3f3f 7 #define N 2505 8 #define re register 9 #define Ii inline int 10 #define Il inline long long 11 #define Iv inline void 12 #define Ib inline bool 13 #define If inline float 14 #define Id inline double 15 #define Ic inline char 16 #define ll long long 17 #define Fill(a,b) memset(a,b,sizeof(a)) 18 #define R(a,b,c) for(register int a=b;a<=c;++a) 19 #define nR(a,b,c) for(register int a=b;a>=c;--a) 20 #define Min(a,b) ((a)<(b)?(a):(b)) 21 #define Max(a,b) ((a)>(b)?(a):(b)) 22 #define Cmin(a,b) ((a)=(a)<(b)?(a):(b)) 23 #define Cmax(a,b) ((a)=(a)>(b)?(a):(b)) 24 #define D_e(x) printf(" &__ %d __& ",x) 25 Ii read(){ 26 int s=0,f=1;char c; 27 for(c=getchar();c>'9'||c<'0';c=getchar())if(c=='-')f=-1; 28 while(c>='0'&&c<='9')s=s*10+(c^'0'),c=getchar(); 29 return s*f; 30 } 31 Iv print(ll x){ 32 if(x<0)putchar('-'),x=-x; 33 if(x>9)print(x/10); 34 putchar(x%10^'0'); 35 } 36 using namespace std; 37 /* 38 The Code Below Is Used To Show The Main Graph Ans The Letters. 39 Used Function: 40 Init_Screen() 41 show_love_word() 42 Init_First_top() 43 screen_down_flower() 44 Init_First_down() 45 show_piercing_arrow() 46 Init_First() 47 */ 48 pthread_mutex_t mutex;//互斥信号量 49 pthread_cond_t cond;//条件变量 50 HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE); 51 _TCHAR buffer[25][80]={ _T(' ') }; 52 _TCHAR ramp[] = _T(".:-=+*#%@"); 53 WORD hjzgg_color[7]={ 54 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 55 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 56 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 57 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 58 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 59 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, 60 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN 61 /* 62 This Is Colors From Internet 63 enmCFC_Red = FOREGROUND_INTENSITY | FOREGROUND_RED, 64 enmCFC_Green = FOREGROUND_INTENSITY | FOREGROUND_GREEN, 65 enmCFC_Blue = FOREGROUND_INTENSITY | FOREGROUND_BLUE, 66 enmCFC_Yellow = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN, 67 enmCFC_Purple = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, 68 enmCFC_Cyan = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, 69 enmCFC_Gray = FOREGROUND_INTENSITY, 70 enmCFC_White = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 71 enmCFC_HighWhite = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, 72 enmCFC_Black = 0, 73 enmCBC_Red = BACKGROUND_INTENSITY | BACKGROUND_RED, 74 enmCBC_Green = BACKGROUND_INTENSITY | BACKGROUND_GREEN, 75 enmCBC_Blue = BACKGROUND_INTENSITY | BACKGROUND_BLUE, 76 enmCBC_Yellow = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN, 77 enmCBC_Purple = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE, 78 enmCBC_Cyan = BACKGROUND_INTENSITY | BACKGROUND_GREEN | BACKGROUND_BLUE, 79 enmCBC_White = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, 80 enmCBC_HighWhite = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, 81 enmCBC_Black = 0, 82 */ 83 84 /* 85 This Is The Origin Color: 86 87 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_GREEN | BACKGROUND_RED|BACKGROUND_GREEN, 88 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, 89 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, 90 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN | BACKGROUND_RED|BACKGROUND_GREEN, 91 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, 92 BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN 93 */ 94 }; 95 If f(float x,float y,float z){ 96 float a=x*x+9.0f/4.0f*y*y+z*z-1; 97 return a*a*a-x*x*z*z*z-9.0f/80.0f*y*y*z*z*z; 98 } 99 If h(float x,float z){ 100 for(float y=1.0f;y>=0.0f;y-=0.001f) 101 if(f(x,y,z)<=0.0f) 102 return y; 103 return 0.0f; 104 } 105 char flower1[11][22]={ 106 " {@} ", 107 " {@} * {@} ", 108 " {@} * {@} * {@} ", 109 "{@}* {@} * {@} * {@}", 110 " \ {@} * {@} * {@} /", 111 " \ \ \ L / / / ", 112 " \\ \ O / // ", 113 " \\ V // ", 114 " \\E// ", 115 " >=< ", 116 " //*\\ " 117 }; 118 char flower2[9][28]={ 119 ".....@---------------@.....", 120 "-- @ @ @ --------- @ @ @ --", 121 ".@ @\@/@ @-------@ @\@/@ @.", 122 ".\@|@|@|@/-....--\@|@|@|@/.", 123 ". \\\|/// --..--- \\\|/// -", 124 " - \\|// --..----- \\|//.--", 125 " -- \|/--..---.---- \|/---.", 126 " -- =&= ---..------ =&= ---", 127 " -- /|\ --------.---/|\ -.-" 128 }; 129 char piercing_arrow[][34]={ 130 " ☆☆ ☆☆ ☆☆ ☆☆ ", 131 " ★★ ★ ★★ ", 132 " ☆☆ HAPPY EVERY DAY ☆☆ ", 133 " ★★ ★★ ", 134 ">>>---------I LOVE YOU --------->", 135 " ★★ ★★ ", 136 " ☆☆ ☆☆ ", 137 " ★★ ★★ ", 138 " ☆☆ " 139 }; 140 char love_word[][6][60]={ 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 Iv Init_Screen(){ 171 COORD size={100,40}; 172 SetConsoleScreenBufferSize(o,size);//Resetting Buffer Size 173 SMALL_RECT rc={0,0,100-1,40-1}; //Reset window position and size 174 SetConsoleWindowInfo(o,true,&rc); 175 SetConsoleTitle("LOVE"); 176 system("color dc");//Set Color 177 } 178 Iv* show_love_word(void* arg){ 179 srand((unsigned)time(NULL));//Rand To Show Flowers 180 while(1) { 181 int word_index=rand()%5,col=70,row_index=3; 182 if(word_index==4) 183 row_index=6; 184 //Show "word" 185 int color_index=rand()%4; 186 for(int i=0;i<row_index;++i){ 187 int row=1; 188 for(int j=0;love_word[word_index][i][j];j+=2){ 189 char one_word[2];//Get A Chinese Character 190 sprintf(one_word,"%c%c",love_word[word_index][i][j],love_word[word_index][i][j+1]); 191 COORD coord={col,row}; 192 pthread_mutex_lock(&mutex); 193 SetConsoleTextAttribute(o,hjzgg_color[color_index]); 194 SetConsoleCursorPosition(o,coord); 195 WriteConsole(o,one_word,2,NULL,0); 196 ++coord.Y;// 197 if(love_word[word_index][i][j+2]){ 198 SetConsoleCursorPosition(o,coord); 199 WriteConsole(o,"__",2,NULL,0); 200 } 201 SetConsoleTextAttribute(o,hjzgg_color[0]); 202 pthread_mutex_unlock(&mutex); 203 ++row; 204 Sleep(100); 205 } 206 col+=4; 207 } 208 Sleep(2000); 209 //Erase "Word" 210 col-=4; 211 for(int i=row_index-1;i>=0;--i){ 212 char hjzgg_word[60]; 213 memcpy(hjzgg_word,love_word[word_index][i],sizeof(love_word[word_index][i])); 214 int len_hjzgg_word=strlen(hjzgg_word); 215 int len_word=len_hjzgg_word; 216 bool is_first=1; 217 while(len_word>=0){ 218 int row=1; 219 for(int j=0;j<len_hjzgg_word;j+=2){ 220 char one_word[2];//Get A Chinese Character 221 sprintf(one_word,"%c%c",hjzgg_word[j],hjzgg_word[j+1]); 222 COORD coord={col,row}; 223 pthread_mutex_lock(&mutex); 224 SetConsoleTextAttribute(o,hjzgg_color[color_index]); 225 SetConsoleCursorPosition(o,coord); 226 WriteConsole(o,one_word,2,NULL,0); 227 ++coord.Y;// 228 if(j+2==len_word){ 229 SetConsoleCursorPosition(o,coord); 230 WriteConsole(o,"__",2,NULL,0); 231 ++row; 232 } 233 SetConsoleTextAttribute(o,hjzgg_color[0]); 234 pthread_mutex_unlock(&mutex); 235 ++row; 236 } 237 if(is_first){ 238 is_first=0; 239 hjzgg_word[len_hjzgg_word++]=' '; 240 hjzgg_word[len_hjzgg_word++]=' '; 241 } 242 else 243 len_hjzgg_word-=2; 244 hjzgg_word[--len_word]=' '; 245 hjzgg_word[--len_word]=' '; 246 Sleep(20); 247 } 248 col-=4; 249 } 250 Sleep(1000); 251 } 252 } 253 void* Init_First_top(void* arg){ 254 char tmp[80]; 255 R(ld,0,11){ 256 COORD coord_top={0,ld}; 257 memset(tmp,' ',sizeof(tmp)); 258 int cc=0; 259 while(cc<60){ 260 while(buffer[ld][cc]==' ')++cc; 261 tmp[cc]=buffer[ld][cc]; 262 ++cc; 263 pthread_mutex_lock(&mutex); 264 SetConsoleCursorPosition(o,coord_top); 265 WriteConsole(o,tmp,60,NULL,0); 266 pthread_mutex_unlock(&mutex); 267 Sleep(15); 268 } 269 } 270 } 271 void* screen_down_flower(void* arg){//Print From Line 26 272 srand((unsigned)time(NULL));//Rand To Show The Flowers 273 int flower_row[3]={11,9,11},flower_col[3]={20,27,20},flower_begin_col[3]={5,33,70},flower_begin_row[3]={26,28,26}; 274 struct timeval now; 275 struct timespec outtime; 276 pthread_mutex_lock(&mutex); 277 while(1){ 278 int k=0; 279 while(k<3){ 280 char flower[50][50]={' '}; 281 int color_index=rand()%7; 282 SetConsoleTextAttribute(o, hjzgg_color[color_index]); 283 if(k==0||k==2) 284 R(i,0,flower_row[k]-1) 285 R(j,0,flower_col[k]-1) 286 flower[i][j]=flower1[i][j]; 287 else 288 R(i,0,flower_row[k]-1) 289 R(j,0,flower_col[k]-1) 290 flower[i][j]=flower2[i][j]; 291 for(int i=flower_begin_row[k],j=0;j<flower_row[k];++i,++j){ 292 COORD coord={flower_begin_col[k],i}; 293 SetConsoleCursorPosition(o,coord), 294 WriteConsole(o,flower[j],flower_col[k],NULL,0); 295 } 296 ++k; 297 SetConsoleTextAttribute(o,hjzgg_color[0]);//Set The Color Before 298 gettimeofday(&now,NULL); 299 outtime.tv_sec=now.tv_sec; 300 outtime.tv_nsec=now.tv_usec*100000; 301 pthread_cond_timedwait(&cond,&mutex,&outtime); 302 } 303 } 304 pthread_mutex_unlock(&mutex); 305 } 306 void* Init_First_down(void* arg){ 307 char tmp[80]; 308 R(rd,24,12){ 309 COORD coord_down={0,rd}; 310 SetConsoleCursorPosition(o, coord_down); 311 memset(tmp,' ',sizeof(tmp)); 312 int cc=60; 313 while(cc>=0){ 314 while(buffer[rd][cc]==' ')--cc; 315 tmp[cc]=buffer[rd][cc]; 316 --cc; 317 pthread_mutex_lock(&mutex); 318 SetConsoleCursorPosition(o,coord_down); 319 WriteConsole(o,tmp,60,NULL,0); 320 pthread_mutex_unlock(&mutex); 321 Sleep(15); 322 } 323 } 324 } 325 Iv show_piercing_arrow(){ 326 R(i,0,8){ 327 pthread_mutex_lock(&mutex); 328 COORD coord_down={13,i+7}; 329 SetConsoleCursorPosition(o,coord_down), 330 WriteConsole(o,piercing_arrow[i],33,NULL,0), 331 pthread_mutex_unlock(&mutex); 332 } 333 } 334 Iv Init_First(){ 335 show_piercing_arrow(); 336 pthread_t tid[4]; 337 pthread_create(&tid[2],NULL,screen_down_flower,NULL),//Screen_down_flower 338 pthread_create(&tid[3],NULL,show_love_word,NULL),//Show_love_word 339 pthread_mutex_init(&mutex,NULL),//Heart Like Init_first 340 pthread_cond_init(&cond, NULL), 341 pthread_create(&tid[0],NULL,Init_First_top,NULL), 342 pthread_create(&tid[1],NULL,Init_First_down,NULL), 343 pthread_join(tid[0], NULL), 344 pthread_join(tid[1], NULL); 345 } 346 /* 347 The Code Below Is Used To Show A Love Heart Crash. 348 Used Function: 349 SetColor() 350 Show_Heart_Crash() 351 */ 352 Iv SetColor(unsigned short color_fore,unsigned short color_back){ 353 HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE); 354 SetConsoleTextAttribute(hCon,(color_fore%16)|(color_back%16*16)); 355 } 356 Iv Show_Heart_Crash(){ 357 int i,s=0,t,a=10,b=11,c=12,d=13,e=14,z[]={32,32,206,210,207,178,187,182,196,227,33,32,32};float x,y; 358 srand(time(NULL)); 359 for(y=1.3;y>=-1.1;y-=0.1){ 360 for(x=-2;x<1.4;x+=0.053){ 361 if(((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0){ 362 if(y>=1.3-10*0.1||y<=1.3-11*0.1){ 363 ++s; 364 if(s%4==1)SetColor(a,0),printf("l"); 365 if(s%4==2)SetColor(e,0),printf("o"); 366 if(s%4==3)SetColor(c,0),printf("v"); 367 if(s%4==0)SetColor(d,0),printf("e"); 368 } 369 else{ 370 for(i=0;i<42;++i){ 371 if(i<=14||i>=28){ 372 ++s; 373 if(s%4==1)SetColor(a,0),printf("l"); 374 if(s%4==2)SetColor(e,0),printf("o"); 375 if(s%4==3)SetColor(c,0),printf("v"); 376 if(s%4==0)SetColor(d,0),printf("e"); 377 } 378 else 379 SetColor(b,0),printf("%c",z[i-15]),Sleep(50); 380 } 381 break; 382 } 383 } 384 else 385 printf(" "); 386 Sleep(1); 387 } 388 printf(" "); 389 } 390 printf("Ready For Love Rush?"); 391 Sleep(1800); 392 R(T,1,30){ 393 system("cls"); 394 t=a,a=b,b=c,c=d,d=e,e=t; 395 for(y=1.3;y>=-1.1;y-=0.1){ 396 for(x=-2;x<1.4;x+=0.053){ 397 if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0)){ 398 if(y>=1.3-10*0.1||y<=1.3-11*0.1){ 399 ++s; 400 if(s%4==1)SetColor(a,0),printf("l"); 401 if(s%4==2)SetColor(b,0),printf("o"); 402 if(s%4==3)SetColor(c,0),printf("v"); 403 if(s%4==0)SetColor(d,0),printf("e"); 404 } 405 else{ 406 for(i=0;i<42;++i){ 407 if(i<=14||i>=28){ 408 ++s; 409 if(s%4==1)SetColor(a,0),printf("l"); 410 if(s%4==2)SetColor(b,0),printf("o"); 411 if(s%4==3)SetColor(c,0),printf("v"); 412 if(s%4==0)SetColor(d,0),printf("e"); 413 } 414 else 415 SetColor(e,0),printf("%c", z[i-15]); 416 } 417 break; 418 } 419 } 420 else 421 printf(" "); 422 } 423 printf(" "); 424 } 425 } 426 } 427 /* 428 The Code Below Is Used To Show A Love Heart Crash With Quick Color Change. 429 Used Function: 430 Show_Heart_Color_Changer_Crash() 431 */ 432 Iv Show_Heart_Color_Changer_Crash(){ 433 for(int i=1,a=20;i<20/2;++i,--a){ 434 nR(j,(int)(20-sqrt(20*20-(a-i)*(a-i))),1)printf(" "); 435 R(e,1,2*sqrt(20*20-(a-i)*(a-i)))printf("3"); 436 nR(j,(int)(2*(20-sqrt(20*20-(a-i)*(a-i)))),1)printf(" "); 437 R(e,1,2*sqrt(20*20-(a-i)*(a-i)))printf("3"); 438 printf(" "); 439 } 440 R(i,1,80-1){ 441 if(i==25) 442 printf(" I Love You "),i+=30; 443 printf("3"); 444 } 445 printf(" "); 446 R(i,1,340/2){ 447 if(i%2||i%3)continue; 448 nR(j,(int)(340-sqrt(340*340-i*i)),1)printf(" "); 449 R(e,1,2*(sqrt(340*340-i*i)-(340-2*20)))printf("3"); 450 printf(" "); 451 } 452 while(1){ 453 system("color a"),Sleep(50), 454 system("color b"),Sleep(50), 455 system("color c"),Sleep(50), 456 system("color d"),Sleep(50), 457 system("color e"),Sleep(50), 458 system("color f"),Sleep(50), 459 system("color 0"),Sleep(50), 460 system("color 1"),Sleep(50), 461 system("color 2"),Sleep(50), 462 system("color 3"),Sleep(50), 463 system("color 4"),Sleep(50), 464 system("color 5"),Sleep(50), 465 system("color 6"),Sleep(50), 466 system("color 7"),Sleep(50), 467 system("color 8"),Sleep(50), 468 system("color 9"),Sleep(50), 469 system("color ab"),Sleep(50), 470 system("color ac"),Sleep(50), 471 system("color ad"),Sleep(50), 472 system("color ae"),Sleep(50), 473 system("color af"),Sleep(50); 474 } 475 } 476 /* 477 With All The Help From These Functions,It's Time To Rock The Main(). 478 */ 479 int main(){ 480 /* 481 Author: Richard. 482 Diet: 483 Dec 14: 484 Prepared Some Sources. 485 Dec 15: 486 Successfully Gathered Three Programes Together. 487 488 The Programe Is Learnt From Internet. 489 I Copied A Few Lines Of Code Which I Cannot Understand Now. 490 But I Also Added My Own Idea Inside. 491 Dear HQ, 492 Do You Like It? 493 */ 494 Show_Heart_Crash(); 495 system("cls"), 496 Sleep(240); 497 Init_Screen(); 498 bool first=1; 499 for(float t=0.0f;;t+=0.1f){ 500 int sy=0; 501 float s=sinf(t),a=s*s*s*s*0.2f; 502 for(float z=1.3f;z>-1.2f;z-=0.1f){ 503 _TCHAR* p=&buffer[sy++][0]; 504 float tz=z*(1.2f-a); 505 for(float x=-1.5f;x<1.5f;x+=0.05f){ 506 float tx=x*(1.2f+a),v=f(tx,0.0f,tz); 507 if(v<=0.0f){ 508 float y0=h(tx,tz),ny=0.01f,nx=h(tx+ny,tz)-y0,nz=h(tx,tz+ny)-y0,nd=1.0f/sqrtf(nx*nx+ny*ny+nz*nz),d=(nx+ny-nz)*nd*0.5f+0.5f; 509 *p++=ramp[(int)(d*5.0f)]; 510 } 511 else 512 *p++=' '; 513 } 514 } 515 if(first) 516 first=0,Init_First(); 517 else{ 518 pthread_mutex_lock(&mutex); 519 for(sy=0;sy<25;++sy){ 520 COORD coord={0,sy}; 521 SetConsoleCursorPosition(o,coord), 522 WriteConsole(o,buffer[sy],60,NULL,0); 523 } 524 pthread_mutex_unlock(&mutex); 525 } 526 Sleep(25); 527 } 528 Show_Heart_Color_Changer_Crash(); 529 return 0; 530 }
```cpp
#include<bits/stdc++.h> #include<windows.h> //#include<pthread.h> #include<tchar.h> #include<sys/time.h> #define INF 0x3f3f3f3f3f3f3f3f #define N 2505 #define re register #define Ii inline int #define Il inline long long #define Iv inline void #define Ib inline bool #define If inline float #define Id inline double #define Ic inline char #define ll long long #define Fill(a,b) memset(a,b,sizeof(a)) #define R(a,b,c) for(register int a=b;a<=c;++a) #define nR(a,b,c) for(register int a=b;a>=c;--a) #define Min(a,b) ((a)<(b)?(a):(b)) #define Max(a,b) ((a)>(b)?(a):(b)) #define Cmin(a,b) ((a)=(a)<(b)?(a):(b)) #define Cmax(a,b) ((a)=(a)>(b)?(a):(b)) #define D_e(x) printf(" &__ %d __& ",x) Ii read(){ int s=0,f=1;char c; for(c=getchar();c>'9'||c<'0';c=getchar())if(c=='-')f=-1; while(c>='0'&&c<='9')s=s*10+(c^'0'),c=getchar(); return s*f; } Iv print(ll x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10^'0'); } using namespace std; /* The Code Below Is Used To Show The Main Graph Ans The Letters. Used Function: Init_Screen() show_love_word() Init_First_top() screen_down_flower() Init_First_down() show_piercing_arrow() Init_First() */ pthread_mutex_t mutex;//????? pthread_cond_t cond;//???? HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE); _TCHAR buffer[25][80]={ _T(' ') }; _TCHAR ramp[] = _T(".:-=+*#%@"); WORD hjzgg_color[7]={ BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_BLUE|FOREGROUND_GREEN /* This Is Colors From Internet enmCFC_Red = FOREGROUND_INTENSITY | FOREGROUND_RED, enmCFC_Green = FOREGROUND_INTENSITY | FOREGROUND_GREEN, enmCFC_Blue = FOREGROUND_INTENSITY | FOREGROUND_BLUE, enmCFC_Yellow = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN, enmCFC_Purple = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE, enmCFC_Cyan = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, enmCFC_Gray = FOREGROUND_INTENSITY, enmCFC_White = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, enmCFC_HighWhite = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, enmCFC_Black = 0, enmCBC_Red = BACKGROUND_INTENSITY | BACKGROUND_RED, enmCBC_Green = BACKGROUND_INTENSITY | BACKGROUND_GREEN, enmCBC_Blue = BACKGROUND_INTENSITY | BACKGROUND_BLUE, enmCBC_Yellow = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN, enmCBC_Purple = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_BLUE, enmCBC_White = BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, enmCBC_HighWhite = BACKGROUND_INTENSITY | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE, enmCBC_Black = 0, */ /* This Is The Origin Color: BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_GREEN | BACKGROUND_RED|BACKGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN | BACKGROUND_RED|BACKGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN, BACKGROUND_INTENSITY|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE | BACKGROUND_RED|BACKGROUND_GREEN */ }; If f(float x,float y,float z){ float a=x*x+9.0f/4.0f*y*y+z*z-1; return a*a*a-x*x*z*z*z-9.0f/80.0f*y*y*z*z*z; } If h(float x,float z){ for(float y=1.0f;y>=0.0f;y-=0.001f) if(f(x,y,z)<=0.0f) return y; return 0.0f; } char flower1[11][22]={ " {@} ", " {@} * {@} ", " {@} * {@} * {@} ", "{@}* {@} * {@} * {@}", " \ {@} * {@} * {@} /", " \ \ \ L / / / ", " \\ \ O / // ", " \\ V // ", " \\E// ", " >=< ", " //*\\ " }; char flower2[9][28]={ ".....@---------------@.....", "-- @ @ @ --------- @ @ @ --", ".@ @\@/@ @-------@ @\@/@ @.", ".\@|@|@|@/-....--\@|@|@|@/.", ". \\\|/// --..--- \\\|/// -", " - \\|// --..----- \\|//.--", " -- \|/--..---.---- \|/---.", " -- =&= ---..------ =&= ---", " -- /|\ --------.---/|\ -.-" }; char piercing_arrow[][34]={ " ?? ?? ?? ?? ", " ?? ? ?? ", " ?? HAPPY EVERY DAY ?? ", " ?? ?? ", ">>>---------I LOVE YOU --------->", " ?? ?? ", " ?? ?? ", " ?? ?? ", " ?? " }; char love_word[][6][60]={ { "你 如 水 的 眸 光 笼 着 江 南 的 烟 雨", "映 入 我 那 一 寸 一 寸 消 融 的 心", "从 那 一 刻 我 不 在 属 于 自 己" }, { "我 默 默 收 集 你 的 所 有", "不 知 还 要 多 久", "却 不 曾 厌 倦" }, { "当 初 ,初 见 只 道 是 寻 常", "寻 觅 ,何 枝 可 化 深 千 亿", "犹 道 ,碧 桃 影 里 碧 三 声" } , { "在 这 个 年 纪 远 远 地 看 着 你", "日 光 美 好 的 一 泻 千 里", "温 暖 着 一 个 卑 微 而 简 单 的 心" } , { "你 的 一 纸 信 笺", "压 在 书 底", "压 过 了 青 春 的 夏 季", "从 爱 你 的 花 季", "一 直 等 到", "爱 你 的 暮 年" } } ; Iv Init_Screen(){ COORD size={100,40}; SetConsoleScreenBufferSize(o,size);//Resetting Buffer Size SMALL_RECT rc={0,0,100-1,40-1}; //Reset window position and size SetConsoleWindowInfo(o,true,&rc); SetConsoleTitle("LOVE"); system("color dc");//Set Color } Iv* show_love_word(void* arg){ srand((unsigned)time(NULL));//Rand To Show Flowers while(1) { int word_index=rand()%5,col=70,row_index=3; if(word_index==4) row_index=6; //Show "word" int color_index=rand()%4; for(int i=0;i<row_index;++i){ int row=1; for(int j=0;love_word[word_index][i][j];j+=2){ char one_word[2];//Get A Chinese Character sprintf(one_word,"%c%c",love_word[word_index][i][j],love_word[word_index][i][j+1]); COORD coord={col,row}; pthread_mutex_lock(&mutex); SetConsoleTextAttribute(o,hjzgg_color[color_index]); SetConsoleCursorPosition(o,coord); WriteConsole(o,one_word,2,NULL,0); ++coord.Y;// if(love_word[word_index][i][j+2]){ SetConsoleCursorPosition(o,coord); WriteConsole(o,"__",2,NULL,0); } SetConsoleTextAttribute(o,hjzgg_color[0]); pthread_mutex_unlock(&mutex); ++row; Sleep(100); } col+=4; } Sleep(2000); //Erase "Word" col-=4; for(int i=row_index-1;i>=0;--i){ char hjzgg_word[60]; memcpy(hjzgg_word,love_word[word_index][i],sizeof(love_word[word_index][i])); int len_hjzgg_word=strlen(hjzgg_word); int len_word=len_hjzgg_word; bool is_first=1; while(len_word>=0){ int row=1; for(int j=0;j<len_hjzgg_word;j+=2){ char one_word[2];//Get A Chinese Character sprintf(one_word,"%c%c",hjzgg_word[j],hjzgg_word[j+1]); COORD coord={col,row}; pthread_mutex_lock(&mutex); SetConsoleTextAttribute(o,hjzgg_color[color_index]); SetConsoleCursorPosition(o,coord); WriteConsole(o,one_word,2,NULL,0); ++coord.Y;// if(j+2==len_word){ SetConsoleCursorPosition(o,coord); WriteConsole(o,"__",2,NULL,0); ++row; } SetConsoleTextAttribute(o,hjzgg_color[0]); pthread_mutex_unlock(&mutex); ++row; } if(is_first){ is_first=0; hjzgg_word[len_hjzgg_word++]=' '; hjzgg_word[len_hjzgg_word++]=' '; } else len_hjzgg_word-=2; hjzgg_word[--len_word]=' '; hjzgg_word[--len_word]=' '; Sleep(20); } col-=4; } Sleep(1000); } } void* Init_First_top(void* arg){ char tmp[80]; R(ld,0,11){ COORD coord_top={0,ld}; memset(tmp,' ',sizeof(tmp)); int cc=0; while(cc<60){ while(buffer[ld][cc]==' ')++cc; tmp[cc]=buffer[ld][cc]; ++cc; pthread_mutex_lock(&mutex); SetConsoleCursorPosition(o,coord_top); WriteConsole(o,tmp,60,NULL,0); pthread_mutex_unlock(&mutex); Sleep(15); } } } void* screen_down_flower(void* arg){//Print From Line 26 srand((unsigned)time(NULL));//Rand To Show The Flowers int flower_row[3]={11,9,11},flower_col[3]={20,27,20},flower_begin_col[3]={5,33,70},flower_begin_row[3]={26,28,26}; struct timeval now; struct timespec outtime; pthread_mutex_lock(&mutex); while(1){ int k=0; while(k<3){ char flower[50][50]={' '}; int color_index=rand()%7; SetConsoleTextAttribute(o, hjzgg_color[color_index]); if(k==0||k==2) R(i,0,flower_row[k]-1) R(j,0,flower_col[k]-1) flower[i][j]=flower1[i][j]; else R(i,0,flower_row[k]-1) R(j,0,flower_col[k]-1) flower[i][j]=flower2[i][j]; for(int i=flower_begin_row[k],j=0;j<flower_row[k];++i,++j){ COORD coord={flower_begin_col[k],i}; SetConsoleCursorPosition(o,coord), WriteConsole(o,flower[j],flower_col[k],NULL,0); } ++k; SetConsoleTextAttribute(o,hjzgg_color[0]);//Set The Color Before gettimeofday(&now,NULL); outtime.tv_sec=now.tv_sec; outtime.tv_nsec=now.tv_usec*100000; pthread_cond_timedwait(&cond,&mutex,&outtime); } } pthread_mutex_unlock(&mutex); } void* Init_First_down(void* arg){ char tmp[80]; R(rd,24,12){ COORD coord_down={0,rd}; SetConsoleCursorPosition(o, coord_down); memset(tmp,' ',sizeof(tmp)); int cc=60; while(cc>=0){ while(buffer[rd][cc]==' ')--cc; tmp[cc]=buffer[rd][cc]; --cc; pthread_mutex_lock(&mutex); SetConsoleCursorPosition(o,coord_down); WriteConsole(o,tmp,60,NULL,0); pthread_mutex_unlock(&mutex); Sleep(15); } } } Iv show_piercing_arrow(){ R(i,0,8){ pthread_mutex_lock(&mutex); COORD coord_down={13,i+7}; SetConsoleCursorPosition(o,coord_down), WriteConsole(o,piercing_arrow[i],33,NULL,0), pthread_mutex_unlock(&mutex); } } Iv Init_First(){ show_piercing_arrow(); pthread_t tid[4]; pthread_create(&tid[2],NULL,screen_down_flower,NULL),//Screen_down_flower pthread_create(&tid[3],NULL,show_love_word,NULL),//Show_love_word pthread_mutex_init(&mutex,NULL),//Heart Like Init_first pthread_cond_init(&cond, NULL), pthread_create(&tid[0],NULL,Init_First_top,NULL), pthread_create(&tid[1],NULL,Init_First_down,NULL), pthread_join(tid[0], NULL), pthread_join(tid[1], NULL); } /* 347 The Code Below Is Used To Show A Love Heart Crash. 348 Used Function: 349 SetColor() 350 Show_Heart_Crash() 351 */ Iv SetColor(unsigned short color_fore,unsigned short color_back){ HANDLE hCon=GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hCon,(color_fore%16)|(color_back%16*16)); } Iv Show_Heart_Crash(){ int i,s=0,t,a=10,b=11,c=12,d=13,e=14,z[]={32,32,206,210,207,178,187,182,196,227,33,32,32};float x,y; srand(time(NULL)); for(y=1.3;y>=-1.1;y-=0.1){ for(x=-2;x<1.4;x+=0.053){ if(((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0){ if(y>=1.3-10*0.1||y<=1.3-11*0.1){ ++s; if(s%4==1)SetColor(a,0),printf("l"); if(s%4==2)SetColor(e,0),printf("o"); if(s%4==3)SetColor(c,0),printf("v"); if(s%4==0)SetColor(d,0),printf("e"); } else{ for(i=0;i<42;++i){ if(i<=14||i>=28){ ++s; if(s%4==1)SetColor(a,0),printf("l"); if(s%4==2)SetColor(e,0),printf("o"); if(s%4==3)SetColor(c,0),printf("v"); if(s%4==0)SetColor(d,0),printf("e"); } else SetColor(b,0),printf("%c",z[i-15]),Sleep(50); } break; } } else printf(" "); Sleep(1); } printf(" "); } printf("Ready For Love Rush?"); Sleep(1800); R(T,1,30){ system("cls"); t=a,a=b,b=c,c=d,d=e,e=t; for(y=1.3;y>=-1.1;y-=0.1){ for(x=-2;x<1.4;x+=0.053){ if((((x*x+y*y-1)*(x*x+y*y-1)*(x*x+y*y-1)-x*x*y*y*y)<=0)){ if(y>=1.3-10*0.1||y<=1.3-11*0.1){ ++s; if(s%4==1)SetColor(a,0),printf("l"); if(s%4==2)SetColor(b,0),printf("o"); if(s%4==3)SetColor(c,0),printf("v"); if(s%4==0)SetColor(d,0),printf("e"); } else{ for(i=0;i<42;++i){ if(i<=14||i>=28){ ++s; if(s%4==1)SetColor(a,0),printf("l"); if(s%4==2)SetColor(b,0),printf("o"); if(s%4==3)SetColor(c,0),printf("v"); if(s%4==0)SetColor(d,0),printf("e"); } else SetColor(e,0),printf("%c", z[i-15]); } break; } } else printf(" "); } printf(" "); } } } /* The Code Below Is Used To Show A Love Heart Crash With Quick Color Change. Used Function: Show_Heart_Color_Changer_Crash() */ Iv Show_Heart_Color_Changer_Crash(){ for(int i=1,a=20;i<20/2;++i,--a){ nR(j,(int)(20-sqrt(20*20-(a-i)*(a-i))),1)printf(" "); R(e,1,2*sqrt(20*20-(a-i)*(a-i)))printf("3"); nR(j,(int)(2*(20-sqrt(20*20-(a-i)*(a-i)))),1)printf(" "); R(e,1,2*sqrt(20*20-(a-i)*(a-i)))printf("3"); printf(" "); } R(i,1,80-1){ if(i==25) printf(" I Love You "),i+=30; printf("3"); } printf(" "); R(i,1,340/2){ if(i%2||i%3)continue; nR(j,(int)(340-sqrt(340*340-i*i)),1)printf(" "); R(e,1,2*(sqrt(340*340-i*i)-(340-2*20)))printf("3"); printf(" "); } while(1){ system("color a"),Sleep(50), system("color b"),Sleep(50), system("color c"),Sleep(50), system("color d"),Sleep(50), system("color e"),Sleep(50), system("color f"),Sleep(50), system("color 0"),Sleep(50), system("color 1"),Sleep(50), system("color 2"),Sleep(50), system("color 3"),Sleep(50), system("color 4"),Sleep(50), system("color 5"),Sleep(50), system("color 6"),Sleep(50), system("color 7"),Sleep(50), system("color 8"),Sleep(50), system("color 9"),Sleep(50), system("color ab"),Sleep(50), system("color ac"),Sleep(50), system("color ad"),Sleep(50), system("color ae"),Sleep(50), system("color af"),Sleep(50); } } /* With All The Help From These Functions,It's Time To Rock The Main(). */ int main(){ /* Author: Richard. Diet: Dec 14: Prepared Some Sources. Dec 15: Successfully Gathered Three Programes Together. The Programe Is Learnt From Internet. I Copied A Few Lines Of Code Which I Cannot Understand Now. But I Also Added My Own Idea Inside. Dear HQ, Do You Like It? */ Show_Heart_Crash(); system("cls"), Sleep(240); Init_Screen(); bool first=1; for(float t=0.0f;;t+=0.1f){ int sy=0; float s=sinf(t),a=s*s*s*s*0.2f; for(float z=1.3f;z>-1.2f;z-=0.1f){ _TCHAR* p=&buffer[sy++][0]; float tz=z*(1.2f-a); for(float x=-1.5f;x<1.5f;x+=0.05f){ float tx=x*(1.2f+a),v=f(tx,0.0f,tz); if(v<=0.0f){ float y0=h(tx,tz),ny=0.01f,nx=h(tx+ny,tz)-y0,nz=h(tx,tz+ny)-y0,nd=1.0f/sqrtf(nx*nx+ny*ny+nz*nz),d=(nx+ny-nz)*nd*0.5f+0.5f; *p++=ramp[(int)(d*5.0f)]; } else *p++=' '; } } if(first) first=0,Init_First(); else{ pthread_mutex_lock(&mutex); for(sy=0;sy<25;++sy){ COORD coord={0,sy}; SetConsoleCursorPosition(o,coord), WriteConsole(o,buffer[sy],60,NULL,0); } pthread_mutex_unlock(&mutex); } Sleep(25); } return 0; }
```
因为换了编辑器的缘故,原来的代码块死了。今天在yyx大哥哥的帮助下终于复活了啦~
公开,公开~
(有些借鉴网上的东东,侵删)