淮聊首页 论坛首页 全部版面 焦点话题 论坛热帖 今日新帖 论坛搜索 论坛指南 聊天室 用户注册 登录  
  您的位置: 淮聊 >> 论坛 >> 情感世界 >> 情感激流 >> 查看贴子
  上篇 刷新 下篇  
 主题:C++代码之爱情篇
号码:154243
呢称:
十三少年
等级:1
积分:2678
主题:391
回复:1037
注册:2002/1/8 13:57:51
发表:2002/7/18 15:09:58 人气:151 楼主
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||the.Girl.感情<0)
theGirl.愿意等=false;
}
if(theBoy.有房==true&&theBoy.有车==true)
theGirl.嫁给(theBoy);
else
{
Boy anotherBoy;
theGirl.恋爱(anotherBoy);
}
}

//注:以上代码尚未编译,请个人自行编译运行,哈哈,祝君顺利
 
-----------------------------------------------------------
<img </font><font style ="FILTER:Glow(Color=FF0000,strngth=1000); FONT-SIZE:40PT; HEIGHT: 0px" <font color=FFFFFF>大家谁会把Flash动画放在论坛上教我啊 !!!!!!!!!!</font></font>

号码:155832
呢称:
党委书记
等级:0
积分:757
主题:131
回复:515
注册:2002/2/3 9:11:18
发表:2002/7/23 22:41:33 第1楼
Re C++代码之爱情篇

不懂C语言
 
-----------------------------------------------------------
<embed width="450" height="328" src="http://202.96.140.81:8000/diy/image/006112.swf"><font style=font:60tp><marquee>轻轻的走了,正如我轻轻的来了!</span>
 本主题共有回复 1 个 本页: 1 -- 1  首页 上页 下页 尾页 切换论坛至:  
  快速回复 注意: *为必填项
 用户号码   请先登录,如果还未注册,请先注册成为新用户!
 帖子标题*   长度不得超过100字
 内容(最大16K)*  
 其它选项   显示签名    Alt+S快速提交
Copyright© 1999-2025 E-mail:zzz000ggg@sina.com 版权所有 苏ICP备05001972号|法律顾问