C++代码之爱情篇爱情经典语录-希望能为意志低沉,漫无目的的你重拾自信,奋勇向上。
/*今在VC论坛上看到一段好代码叫C语言代码人生之爱情篇,各大虾正在热烈讨论,现在哦把它简单地标准C++代码,作为抛砖引玉,供各位大虾继续发挥,写成人生篇,事业篇什么的应该不难,最好写成了一段完整标准的C++语言语法教材*/#include#include#include一些必要头文件#defineNOTHING不需任何东西
classBoy{public:bool有房;bool有车;int年龄;public:Boy();~Boy();void恋爱(Girlgirl);void具备条件(char*another);bool赠送礼物(Girlgirl,char*gift)long拼命赚钱();};
classGirl{public:int感情;bool愿意等;int生日;public:Girl();~Girl();void恋爱(Boyboy);void嫁给(Boyboy);};
Boy::Boy(){inti;i=rand();if(i=100){有房=true;}else{有房=false;}i=rand();if(i=200){有车=true;}else{有车=false;}}
Boy::~Boy(){
}
voidBoy::恋爱(Girlgirl){与girl进入相恋阶段;}
voidBoy::其他具备条件(char*another){#_page_#}{Boy目前拥有的除房子车子外条件=another;}
boolBoy::赠送礼物(Girlgirl,char*gift){
if(Boy将礼物送给girl)returntrue;elsereturnfalse;}
longBoy::拼命赚钱(){Boy日夜操劳,两眼发黑,为的是月末能拿到那可怜的钞票;return一年挣下的钞票总数;}
Girl::Girl(){
}
Girl::~Girl(){}
voidGirl::恋爱(Boyboy){与boy进入相恋阶段;}
voidGirl::嫁给(Boyboy){同意嫁给boy,与boy步入神圣的婚姻殿堂;}
voidmain(){
BoytheBoy;GirltheGirl;intyear;longmoney;
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(intday=1;day{#_page_#}theGirl.感情++;elsetheGirl.感情--;}if(日期转换(day)==theGirl.生日){if(theBoy.赠送礼物(theGirl,玫瑰))theGirl.感情++;elsetheGirl.感情--;}money+=theBoy.拼命赚钱();}if(money>1000000){theBoy.有房=true;theBoy.有车=true;theGirl.愿意等=false;break;}
theBoy.年龄++;theGirl.感情--;
if(theBoy.年龄>30||the.Girl.感情
看完C++代码之爱情篇爱情经典语录还是意犹未尽?欢迎进入语录栏目阅读更多经典语录哦。