當前位置

首頁 > 語文基礎 > 語錄 > C++代碼之愛情篇愛情經典語錄

C++代碼之愛情篇愛情經典語錄

推薦人: 來源: 閱讀: 1.9W 次
C++代碼之愛情篇愛情經典語錄
/*今在VC論壇上看到一段好代碼叫C語言代碼人生之愛情篇,各大蝦正在熱烈討論,
現在哦把它簡單地標準C++代碼,作爲拋磚引玉,供各位大蝦繼續發揮,寫成人
生篇,事業篇什麼的應該不難,最好寫成了一段完整標準的C++語言語法教材*/
#include
#include
#include 一些必要頭文件
#define NOTHING 不需任何東西
class Boy
{
public:
bool 有房;
bool 有車;
int 年齡;
public:
Boy();
~Boy();
void 戀愛(Girl girl);
void 具備條件(char *another);
bool 贈送禮物(Girl girl,char *gift)
long 拼命賺錢();
};
class Girl
{
public:
int 感情;
bool 願意等;
int 生日;
public:
Girl();
~Girl();
void 戀愛(Boy boy);
void 嫁給(Boy boy);
};
Boy::Boy()
{
int i;
i=rand();
if(i=100)
{
有房=true;
}
else
{
有房=false;
}
i=rand();
if(i=200)
{
有車=true;
}
else
{
有車=false;
}
}
Boy::~Boy()
{
}
void Boy::戀愛(Girl girl)
{
與girl進入相戀階段;
}
void Boy::其他具備條件(char *another)
{
Boy目前擁有的除房子車子外條件=another;
}
bool Boy::贈送禮物(Girl girl,char *gift)
{
if(Boy將禮物送給girl)
return true;
else
return false;
}
long Boy::拼命賺錢()
{
Boy日夜操勞,兩眼發黑,爲的是月末能拿到那可憐的鈔票;
return 一年掙下的鈔票總數;
}
Girl::Girl()
{
}
Girl::~Girl()
{
}
void Girl::戀愛(Boy boy)
{
與boy進入相戀階段;
}
void Girl::嫁給(Boy boy)
{
同意嫁給boy,與boy步入神聖的婚姻殿堂;
}
void main( )
{
Boy theBoy;
Girl theGirl;
int year;
long money;
theBoy.年齡=25;
theBoy.戀愛(theGirl);
year=1;
theGirl.感情=1;
theGirl.願意等=true;
theGirl.生日=1001;
money=0;
if( theBoy.有房==true&&theBoy.有車==true)
{
theBoy.其他具備條件(NOTHING);
theGirl.嫁給(theBoy);
return;
}
while (theGirl.願意等==true)
{
for( int day=1; day<=365; day++)
{
if( 節日轉換(day) == 情人節)
{
if( theBoy.贈送禮物(theGirl,玫瑰))
theGirl.感情++;
else
theGirl.感情--;
}
if( 日期轉換(day) == theGirl.生日)
{
if( theBoy.贈送禮物(theGirl,玫瑰))
theGirl.感情++;
else
theGirl.感情--;
}
money+=theBoy.拼命賺錢();
}
if(money>1000000)
{
theBoy.有房=true;
theBoy.有車=true;
theGirl.願意等=false;
break;
}
theBoy.年齡++;
theGirl.感情--;
if(theBoy.年齡>30||.感情<0)
theGirl.願意等=false;
}
if(theBoy.有房==true&&theBoy.有車==true)
theGirl.嫁給(theBoy);
else
{
Boy anotherBoy;
theGirl.戀愛(anotherBoy);
}
}
//注:以上代碼尚未編譯,請個人自行編譯運行,哈哈,祝君順利