首页 > 代码库 > Heart For U

Heart For U

做一个浪漫的程序猿,当LZ看到这个标题的时候就有点好奇,忍不住点了进去看了看,原来笔者写了一个打印heart的程序,还是挺不错的。

想想没做程序猿之前,还是挺浪漫的,如今被贴上码农的身份后,那些浪漫的天分就被磨灭了。如今LZ要重新找回浪漫的天分,从这个Heart做起。

heart.cpp

 1 // Heart.cpp : 定义控制台应用程序的入口点。 2 // 3 #include "stdafx.h" 4 #include <iostream> 5 #include <string> 6 #include <Windows.h> 7 #include<cmath> 8 using std::pow; 9 using namespace std;10 #define m 0.311 #define n 0.612 #define t 1.813 #define r 1.0   //some ratios14 15 #include <conio.h>16 void gotoxy(int x,int y) 17 {18     CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 19     HANDLE   hConsoleOut;20 21     hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);22     GetConsoleScreenBufferInfo(hConsoleOut,&csbiInfo);23 24     csbiInfo.dwCursorPosition.X = x;25     csbiInfo.dwCursorPosition.Y = y;26     SetConsoleCursorPosition(hConsoleOut,csbiInfo.dwCursorPosition);27 }28 int main()29 {30     double x_pos,y_pos;31     double m_pos,n_pos;32     double width=4.0; //width33     double heigh=1.5; //heigh34 35     for(y_pos=heigh,n_pos=heigh;y_pos>=-1.0,n_pos>=-1.0;y_pos-=0.1,n_pos-=0.1)   // y position36     {37         for(x_pos=-3.0,m_pos=-3.0;x_pos,m_pos<=width;x_pos+=0.1,m_pos+=0.1)     // x position38 39         {40             if((pow(n*pow(m_pos,2)+t*pow(n_pos,2)-1.0,3)-t*pow(m_pos,2)*pow(n_pos,3)>=0)41                 &&(pow(m*pow(x_pos,2)+r*pow(y_pos,2)-1.0,3)-r*pow(x_pos,2)*pow(y_pos,3)<0))42                 //the function (n*x^2+t*y^2-1)^3-t*x^2*y^3=043                 cout<<"*";44             else45                 cout<<" ";46         }47         cout<<endl;48 49     }50     string honey = "Dear Honey" ;51     string love = "I LOVE YOU";52     string date = "14-10-1";53     gotoxy(22,9);54     for(int i = 0 ; i<honey.size(); i++){55         cout << honey[i];56         Sleep(200);57     }58     gotoxy(26,11);59     for(int i = 0 ; i<love.size(); i++){60         cout << love[i];61         Sleep(200);62     }63     gotoxy(32,13);64     for(int i = 0 ; i<date.size(); i++){65         cout << date[i];66         Sleep(200);67     }68     gotoxy(0,26);   69     cout <<endl << endl << "press any key to end ..." <<endl;70     getchar();71     return 0;72 }

Heart For U