我可以: 邀请好友来看>>
ZOL星空(中国) > 技术星空(中国) > C/C++星空(中国) > 急求!!昨天写了个小程序~老是自动关闭!求各位大虾帮忙呀~!!多谢
帖子很冷清,卤煮很失落!求安慰
返回列表
签到
手机签到经验翻倍!
快来扫一扫!

急求!!昨天写了个小程序~老是自动关闭!求各位大虾帮忙呀~!!多谢

355浏览 / 7回复

jklovelovelo...

jklovelovelove

0
精华
1
帖子

等  级:Lv.1
经  验:39
  • Z金豆: 0

    千万礼品等你来兑哦~快点击这里兑换吧~

  • 城  市:福建
  • 注  册:2009-12-30
  • 登  录:2010-08-01
发表于 2010-08-01 08:40:16
电梯直达 确定
楼主

aaa.cpp
#include
#include"LOU.h"
using namespace std;
int main()
{
    LOU m(1,0);
    while(1)
  m.gl();
 return 0;
}

ceng.cpp
#include
#include"CENG.h"
#include
#include
#include"REN.h"
#include
CENG::CENG()
{  
 z=0;
 up=0;
 down=0;
}
void CENG::xj()
{
 p=new REN;
 q=p;
 p->next=NULL;
}
void CENG::sc()
{
    int a;
 srand(time(NULL));
    a=rand()%10;
 if(a!=0)
 {
  t=new REN;
  t->next=NULL;
  p->next=t;
  p=p->next;
 }
 cout< getch();
}
void CENG::sb()
{
 p=q->next;
 while(p!=NULL)
 {
  if(p->outqu()>z)
    p->disn(1);
  else
   p->disn(2);
  p=p->next;
 }
 cout< getch();
}
void CENG::tj()
{
 p=q->next;
 while(p!=NULL)
 {
  if(p->outn()==1)
   up++;
  else
   if(p->outn()==2)
    down++;
  p=p->next;
 }
 cout< getch();
}
void CENG::sj(int a)
{
 z=a;
}
int CENG::outup()
{
 return up;
}
int CENG::xs1()
{
 return z;
}
int CENG::xs2()
{
 int a=0;
 p=q->next;
 while(p!=NULL)
 {
  if(p->outqu()>a)
   a=p->outqu();
  p=p->next;
 }
 return a;
}
int CENG::xs3()
{
 int a=0;
 p=q->next;
 while(p!=NULL)
 {
  if(p->outqu()   a=p->outqu();
  p=p->next;
 }
 return a;
}
void CENG::disup()
{
 p=q->next;
 while(p!=NULL)
 {
  if(p->outn()==1)
   p->disn(3);
  p=p->next;
 }
}
void CENG::disdown()
{
 p=q->next;
 while(p!=NULL)
 {
  if(p->outn()==2)
   p->disn(3);
  p=p->next;
 }
}
int CENG::del(int a)
{
 int b=0;
 p=q->next;
 while(p!=NULL)
 {
  if(p->outqu()==a)
  {
   p->disn(0);
   b++;
  }
  p=p->next;
 }
 return b;
}
int CENG::outdown()
{
 return down;
}


ceng.h
#include
#include"REN.h"
using namespace std;
class CENG
{
public:
 void xj();
 void sc();
 void sb();
 void tj();
 void disup();
 void disdown();
 void sj(int);
 int del(int);
 int outup();
 int xs1();
 int xs2();
 int xs3();
 int outdown();
 CENG();
protected:
 int up,z,down;
 REN *p,*q,*t;
};

 

lou.cpp
#include
#include"LOU.h"
#include
#include
#include
LOU::LOU(int a,int b)
{
 n=a;
 m=b;
}
void LOU::out(int n)
{
 int a;
 for(a=19;a>=1;a--)
 {
  if(a!=n)
   cout<<'t'<  else
   cout<<'t'< }
}

void LOU::sc()
{
    srand(time(NULL));
    a=(rand()%19);
 ceng[a].sc();
 ceng[a].sb();
 ceng[a].tj();
}
void LOU::gl()
{
 int i,j,c,d;
 for(i=0;i<19;i++)
 {
  ceng.xj();
  ceng.sj(i+1);
 }
 cout< sc();
 while(1)
 {
  while(n<20)
  {
      for(i=0,c=0;i<19;i++)
   {
             if(ceng.xs2()>n)
           c=1;
   }
   for(i=n+1,d=0;i<20;i++)
   {
    if((ceng[i+1].outup()+ceng[i-1].outdown())!=0)
     d=1;
   }
      if(d==1||c==1)
   {
          out(n);
       getch();
    cout<       n++;
          if(ceng[n-1].outup()>0)
    {
              m=m+ceng[n-1].outup();
           ceng[n-1].disup();
    }
          for(j=0;j<19;j++)
    {
     m=m-ceng[n-1].del(n);
    }
          sc();
   }     
  }
  while(n>2)
  {
   for(i=0,c=0;i<19;i++)
   {
          if(ceng.xs3()        c=1;
   }
   for(i=n-1,d=0;i>2;i--)
   {
    if((ceng[i+1].outup()+ceng[i-1].outdown())!=0)
     d=1;
   }
   if(d=1||c==1)
   {
          out(n);
       getch();
    cout<    n--;
       if(ceng[n-1].outdown()>0)
    {
              m=m+ceng[n-1].outdown();
           ceng[n-1].disdown();
    }
       for(j=0;j<19;j++)
    {
           m=m-ceng[n-1].del(n);
    }
        sc();
   }
  }
 }
}


lou.h
#include
#include"CENG.h"
using namespace std;
class LOU
{
public:
 LOU(int,int);
    void gl();
 void sc();
 void out(int n);
private:
    int n,m,a;
 CENG ceng[19];
};

 

ren.cpp
#include
#include
#include "ren.h"
#include
REN::REN()
{
 srand(time(NULL));
    qu=(rand()%19)+1;
 n=0;
}
void REN::disn(int a)
{
 n=a;
}
int REN::outqu()
{
    return qu;
}
int REN::outn()
{
    return n;
}

 


ren.h
#ifndef    REN_N_N
#define    REN_N_N
#include
using namespace std;
class REN
{
public:
 REN();
 int outqu();
 int outn();
 void disn(int a);
 REN *next;
private:
 int qu;
 int n;
};
#endif

 

sehdan.lee

sehdan.lee


精华

帖子

等  级:Lv.3
经  验:923
发表于 2010-09-13 22:15:10 1楼
代码那么长,又没有注释,又没有解释,又没有描述,三无产品怎么看?
猜你描述的是不是自己点EXE会退出?代码结尾加个输入或者system("pause")

baoby2010

baoby2010


精华

帖子

等  级:Lv.2
经  验:440
发表于 2010-09-22 22:56:07 2楼
严重同意,写代码没好的注释害人害己.

zol_wt

zol_wt


精华

帖子

等  级:Lv.12
经  验:820218
发表于 2010-09-30 22:30:14 3楼
同意

helios1223

helios1223


精华

帖子

等  级:Lv.5
经  验:3040
发表于 2010-10-14 09:09:55 4楼
楼下应该是什么呢??{:8_23

lucktty

lucktty


精华

帖子

等  级:Lv.1
经  验:36
发表于 2010-10-14 15:18:20 5楼
表示看不懂 很乱

limons

limons


精华

帖子

等  级:Lv.4
经  验:2907
发表于 2010-10-29 19:11:27 6楼
用类方法来实现吧,太拉杂了

zmoon53

zmoon53


精华

帖子

等  级:Lv.1
经  验:4
发表于 2010-10-29 22:23:28 7楼
结尾加system("pause")吧

高级模式
星空(中国)精选大家都在看24小时热帖7天热帖大家都在问最新回答

针对ZOL星空(中国)您有任何使用问题和建议 您可以 联系星空(中国)管理员查看帮助  或  给我提意见

快捷回复 APP下载 返回列表