关于本站
管理团队
  
胡杨林-吉林灌水区主题区  [登录] [注册] [发表新文章]  

作者: wanglihui 收藏:0 回复:2 点击:4698 发表时间: 2003.07.04 08:34:16

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; day1000000)
    {
   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);
  }
  }
  
  (二)
  精简的版本:
  
  Poster: NeverGiveUp January 11:
  #define AND &&
  
  RESULT love(boy, girl)
  {
  if( boy.有房() AND boy.有车() )
  {
  boy.Set(Nothing);
  return girl.嫁给(boy);
  }
  else if( girl.愿意等() )
  {
  next_year:
  for( day=1; day〈=365; day++)
  {
  if( day == 情人节 )
  if( boy.GiveGirl(玫瑰+巧克力+anyting valuable) )
  girl.感情++;
  else
  girl.感情--;
  if( day == girl.生日)
  if( boy.GiveGirl(玫瑰+anything valuable) )
  girl.感情++;
  else
  girl.感情--;
  
  boy.拼命赚钱();
  }
  年龄++;
  girl.感情--;
  if( boy.有房() AND boy.有车() )
  {
  boy.Set(Nothing);
  return girl.嫁给(boy);
  }
  else if( boy.赚钱 〉 100,000 AND girl.感情 〉 6 )
  goto next_year;
  else
  return girl.goto( another_boy);
  }
  
  return girl.goto( another_boy);
  }
  
  //注:以上代码尚未编译,请个人自行编译运行,哈哈,祝君顺利
  
  

------------------------
让我成为你的好友

转载    收   藏  

回帖


回复人: 飞天宝宝 Re:C++代码之爱情篇 回复时间: 2003.07.04 11:03

    呵呵 从哪里转来得~~~~~~~~~~~~:)

------------------------
回忆★在时间里沉淀☆时间★在回忆中消失☆感触★在重复中麻木☆我们★在麻木中重复☆爱情★在指逢间承诺☆指逢★在爱情下交缠☆没有★在拥有中挣扎☆拥有★在挣扎里回忆☆

1 篇回复    查 看 回 复    回    复    

回复人: 雪候鸟1981 Re:C++代码之爱情篇 回复时间: 2003.07.10 12:10

    无厘头!

回    复    

回复


回复主题: 回复在论坛 回复到信箱
回复内容:
附加签名:
上传贴图:
图片要求:长宽建议不超过:650×650。大小:300K 以内,文件后缀名必须为:.gif 或.jpg 或.png
      
版主推荐:
文坛新文:
作者其它文章:

Copyright 2002-2008 版权所有
胡杨林© All rights reserved.
服务支持拓商网