With C to write a girlfriend of valentine's day small program lovely!

  • 2020-06-03 07:40:12
  • OfStack

Example of this article for you to share C prepared for the girlfriend of the small program, for your reference, the specific content is as follows


#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; 
//////////////////////////// Higher function  
void SS() 
{ 
 void printchar(); 
 int midw1,midw,midw2; 
 srand((int)time(NULL)); 
 for(hang=gao;hang>=high;hang--)// Rising stage  
 { 
  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");// Clear the screen  
  printchar(); 
  if(hang<gao) 
  { 
   int temp; 
   for(temp=gao;temp>hang;temp--) 
   { 
    if(temp<=hang+5) 
    { 
     yanhua[temp][midw]=20;// Produce the tail  
     yanhua[temp][midw1]=20; 
     yanhua[temp][midw2]=20; 
    } 
    else 
    { 
     yanhua[temp][midw]=0;// Remove the tail  
     yanhua[temp][midw1]=0; 
     yanhua[temp][midw2]=0; 
    } 
   } 
   yanhua[hang+1][midw]=10;// Reset the fireworks head  
   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); 
 } 
} 
 
/////////////////////////////// The explosion function  
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; 
 } 
} 
////////////////////////////// Generate a random number function  
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); 
  } 
 } 
} 
/////////////////////////////// Output graph function  
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<<" low "; 
   else if(yanhua[i][j]==20)cout<<" lots "; 
   else if(yanhua[i][j]==1)cout<<"*"; 
   else if(yanhua[i][j]==2)cout<<" ・ "; 
   else cout<<" "; 
  }// The output of fireworks  
  cout<<endl; 
 } 
} 
//////////////////////// Countdown function  
void djs() 
{ 
 cout<<" Not to be missed... "; 
 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<<" The fireworks start "; 
 Sleep(500); 
} 
///////////////////////// Meteor shower  
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<<" u "; 
      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); 
 } 
} 
////////////////////////////// The output text  
void printword() 
{ 
 char ch; 
 cout<<endl; 
 char Word1[80]=" Send you 1 Winnie the Pooh, let it accompany you every day, and share his honey with you, 1 Sweet to your heart. "; 
 for(i=0;Word1[i]!=NULL;i++) 
 { 
  cout<<Word1[i]; 
  Sleep(50); 
 } 
 cout<<endl; 
 cout<<"  ┴   ┬   ┴   ┬  /  ̄ \ _  ̄ \ "<<endl; 
 cout<<"  ┬   ┴   ┬   ┴   �   �   �   �   �   �  \  "<<endl; 
 cout<<"  ┴   ┬   ┴  / \ /  �   "<<endl; 
 cout<<"  ┬   ┴   �  /)  "<<endl; 
 cout<<" Complaints  ┴   ┬   �   �   "<<endl; 
 cout<<"  ┬   ┴   �   �   �   "<<endl; 
 cout<<"  ┴   �   �   �   �  \ ___ /  "<<endl; 
 cout<<"  ┬   �   �   �   �   �   �  /  "<<endl; 
 cout<<"  ┴   �   �   �   �   �   �   �   �   �   �   �   �   �   �   "<<endl; 
 cout<<"  �   �   �   �   �   �   �   �   �   �   �   �   �   �   �   �   �   "<<endl; 
 cout<<"  �   �   �   �   �   �   �   �   �   �   �   �   �   �   �   �   �  \  "<<endl; 
 cout<<"  �   �   �   �   �   �   �   �   �   �   �   �   �   �   �    \  "<<endl; 
 cout<<"  ┴   �   �   �   �   �   �   �   �   �   �   �   �    �  "<<endl; 
 cout<<"  ┬  │ │  �   �   �   �   �   �   �   "<<endl; 
 cout<<"  ┴  │ │  �   "<<endl; 
 cout<<" ┬    �    /  �   �   �   �  \   �  "<<endl; 
 cout<<" ┴ / Negotiation / \  "<<endl; 
 cout<<"  ┬   ┴   ┬   ┴   ┬   ┴  \      \    �  /   �  "<<endl; 
 cout<<"  ┴   ┬   ┴   ┬   ┴   ┬   ┴    \ \ \   The library is closed    �  \  "<<endl; 
 cout<<" Bring about delta bring bring  �   �   �   �   �   �   �   �   �  \    �    / /  �   �   �   �   "<<endl; 
 cout<<" * * and / /, by the Way  "<<endl; 
} 
/////////////////////////// The main function  
int main() 
{ 
 system("color 0f"); 
 djs();///////////////////////// The countdown  
 for(pc=1;pc<=10;pc++)/////////////// set off fireworks  
 { 
  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]="  Wench, after watching the fireworks, let's see the meteor shower ! Meteor showers aren't common in real life, so let's do it now \n I made it for you 1 A meteor shower! Can take the opportunity to make a wish oh! \n"; 
 for(i=0;Word2[i]!=NULL;i++) 
 { 
  cout<<Word2[i]; 
  Sleep(50); 
 } 
 lxy(); 
 char Word3[100]="  Meteor shower did not do very well, but I also took advantage of the meteor shower to make 1 A wish! How about you? \n"; 
 for(i=0;Word3[i]!=NULL;i++) 
 { 
  cout<<Word3[i]; 
  Sleep(50); 
 } 
 printword(); 
 cout<<" Girl, be happy "; 
 for(flag;flag<=1;flag++)ch=getchar(); 
 exit(0); 
 return 0; 
} 

Since I taught myself C for 2 weeks at that time, my code structure and programming style were not good enough. I will release the improved code gradually in the future.


Related articles: