现在的位置: 首页 > 综合 > 正文

苦中作乐

2014年02月18日 ⁄ 综合 ⁄ 共 309字 ⁄ 字号 评论关闭

用C++写情书

#include "iostream.h"
void main()
{
	cout<<"我现在在烟台,高考前我想去青岛,我想你了……"<<endl;
    cout<<"你猜猜我现在想的数是多少?范围0~1000"<<endl;
  int a,b(0),c(1000),k(520);
re:cin>>a;
   while(a!=k)
 {
  if(a<k)
  {
   b=a;
   cout<<a<<"到"<<c<<"之间"<<endl;
  }
  else
  {
   c=a;
   cout<<b<<"到"<<a<<"之间,请重新输入:"<<endl;
  }
  goto re;
   }
   cout<<"猜对了,520"<<endl;
   cout<<"我爱你,do you know?"<<endl;
}

运行结果:

抱歉!评论已关闭.