第69行、70行、85行是什么问题


#include<iostream>
#include<string> 
#include<windows.h>
using namespace std;
int cnumber=1;
bool windowsn[20];
int bnumber=0;//为机型数量 
int anumber=0;//为工厂数量 
string  name;
double money=800000;
double xinpian=0;
double yinpan=0;
double xianka=0;
double yrxp=0;
double yryp=0;
double yrxk=0;
double yryjpm;
double yejingpinmu; 
bool newcomputer_001();
struct garage
{
    int kind;    //工厂类型        1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 
    int level;//等级 
    int make;  //出产效率
    void newgarage(int a) 
    {
        anumber++;
        level=1;
        make=10000;
        kind =a;
        money-=20000;
        cout<<"的";
        if(a==1)cout<<"芯片";
        if(a==2)cout<<"硬盘";
        if(a==3)cout<<"显卡";
        if(a==4)cout<<"液晶屏幕";
        if(a==5)
        {
            if(newcomputer_001())
            {
                cout<<"组装"<<endl;
                anumber++;
            }
            else
            {
                cout<<"对不起,您的某些材料还未得到无法建造组装工厂";
            } 
        }
        else anumber++;
        if(a=1)yrxp+=10000;
        if(a=2)yryp+=10000;
        if(a=3)yrxk+=10000;
        if(a=4)yryjpm+=10000;
    }
    void upleavle()
    {
        level++;
        if(kind=1)yrxp+=make/2;
        if(kind=2)yryp+=make/2;
        if(kind=3)yrxk+=make/2;
        if(kind=4)yryjpm+=10000;
        make*=1.5;
    } 
};
garage player[100];
struct time
{
    int year;
    year=0;
    int month = 1;
    void timeup()
    {
        if(month==12)
        {
            year++;
            month=1;
        } 
        else month++;
    }
};
int ci;
time the_wrold_time; 
struct computer
{
    int windows=0;//windows等级
    int hot;    //机型热度
    int number; //机型库存 
    int nxp;//需要材料 
    int nyp;
    int nxk;
    int nyjpm;
    void newcomputer()
    {
        bnumber++;
        cout<<"研发新型电脑"<<endl; 
        cout<<"请选择windows等级"<<endl;
        cin>>ci;
        if(windowsn[ci]==true)
        {
            cout<<"好的"<<endl;
        }
        else
        {
            cout<<"系统未授权,请付款2000元"<<endl;
            cout<<"系统已经自动付款" <<endl;
            money-=2000; 
        }
        cout<<"请选择组装工厂投入使用:"<<endl;
        for(int i=1;i<=anumber;i++)
        {
            if(player[i].kind=5)
            {
                cout<<i<<"号工厂"<<endl;
            }
        }
    
    }
};
void typeofficename ()
{
    for(int i=0;i<=name.length()-1;i++)
    {
        cout<<name[i];
    }
}

void prepare()
{
    money=8000000;
    
}
garage a[1001];//暂时无效 
computer b[10000 ];
int main()
{
    cout<<"欢迎来到手机帝国"<<endl;
    Sleep(500);
    cout<<"好了,我们开始吧"<<endl;
    cout<<"先给公司取名吧(不包含空格)"<<endl;
    cin>>name;
    cout<<"注册成功,你的公司:";
    typeofficename(); 
    cout<<endl;
    Sleep(500);
    cout<<"先送给你一笔客观的创业金800万"<<endl;
    Sleep(500); 
    cout<<"先造芯片工厂"<<endl; 
    cout<<"芯片工厂初次建造需要20000元"<<endl;
    Sleep(1000);
    cout<<"系统已经自动帮您办理手续"<<endl;
    player[anumber].newgarage(1);
    cout<<"哦,对了我们这里一月是10秒钟,只不过在教程阶段暂停了一下"<<endl;
    cout<<"你随时都可以建造新工厂"<<endl;
    cout<<"按下1建就可以建造工厂"<<endl;
    Sleep (1000); 
    cout<<"再按下1-5就可以建造不同类型的工厂"<<endl;
    cout<<" 1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 "<<endl;
    Sleep(500);
    cout<<"好的,接下来你就可以创建第一台机器了"<<endl;
    cout<<"按下2来研发型号"<<endl;
    cout<<"可是你需要把所有种类的工厂买下来"<<endl;
    cout<<"哦,对了在回复中回复0就表示撤销"<<endl;
    cout<<"暂时再见"<<endl;
    while(money>= -1000)
    {
        cout<<the_wrold_time.year<<"年"<<the_wrold_time.month<<"月"<<endl;
        cout<<"钱"<<money<<endl;
        cin>>ci;
        if(ci==1)//建造工厂 
        {
            cout<<"执行建造工厂指令"<<endl;
            cout<<"1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 "<<endl;
            cin>>ci; 
            player[anumber].newgarage(ci);
            
        }
        if(ci==0)//撤销 
        {
            cout<<"正在执行撤销指令" <<endl;
        }
        if(ci==2)
        {
            if(newcomputer_001()==true)//newcomputer_001为判断电脑是否可以生产 
            {
                b[bnumber].newcomputer();
            }
            else cout<<"您还有一些原材料的工厂未获得所以无法生产电脑"<<endl;
        }
        Sleep(10000);
        the_wrold_time.timeup();
    }
}
bool newcomputer_001()
{
    if(yrxp==0||yryp==0||yrxk==0||yryjpm==0)
    {
        return false;
    }
    return true;
}

第69行、70行、85行是什么问题?


#include<iostream>
#include<string> 
#include<windows.h>
#include<bits/stdc++.h>
using namespace std;
int cnumber=1;
bool windowsn[20];
int bnumber=0;//为机型数量 
int anumber=0;//为工厂数量 
string  name;
double money=800000;
double xinpian=0;
double yinpan=0;
double xianka=0;
double yrxp=0;
double yryp=0;
double yrxk=0;
double yryjpm;
double yejingpinmu; 
bool newcomputer_001();
struct garage
{
    int kind;    //工厂类型        1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 
    int level;//等级 
    int make;  //出产效率
    void newgarage(int a) 
    {
        anumber++;
        level=1;
        make=10000;
        kind =a;
        money-=20000;
        cout<<"的";
        if(a==1)cout<<"芯片";
        if(a==2)cout<<"硬盘";
        if(a==3)cout<<"显卡";
        if(a==4)cout<<"液晶屏幕";
        if(a==5)
        {
            if(newcomputer_001())
            {
                cout<<"组装"<<endl;
                anumber++;
            }
            else
            {
                cout<<"对不起,您的某些材料还未得到无法建造组装工厂";
            } 
        }
        else anumber++;
        if(a=1)yrxp+=10000;
        if(a=2)yryp+=10000;
        if(a=3)yrxk+=10000;
        if(a=4)yryjpm+=10000;
    }
    void upleavle()
    {
        level++;
        if(kind=1)yrxp+=make/2;
        if(kind=2)yryp+=make/2;
        if(kind=3)yrxk+=make/2;
        if(kind=4)yryjpm+=10000;
        make*=1.5;
    } 
};
garage player[100];
struct ttiimmee{
  //  int yyeeaarr;
    int yyeeaarr=0;
    int mmoonntthh = 1;
    public:
    void ttiimmeeup()
    {
        if(mmoonntthh==12)
        {
            yyeeaarr++;
            mmoonntthh=1;
        } 
        else mmoonntthh++;
    }
};
int ci;
ttiimmee the_wrold_ttiimmee; 
struct computer
{
    int windows=0;//windows等级
    int hot;    //机型热度
    int number; //机型库存 
    int nxp;//需要材料 
    int nyp;
    int nxk;
    int nyjpm;
    void newcomputer()
    {
        bnumber++;
        cout<<"研发新型电脑"<<endl; 
        cout<<"请选择windows等级"<<endl;
        cin>>ci;
        if(windowsn[ci]==true)
        {
            cout<<"好的"<<endl;
        }
        else
        {
            cout<<"系统未授权,请付款2000元"<<endl;
            cout<<"系统已经自动付款" <<endl;
            money-=2000; 
        }
        cout<<"请选择组装工厂投入使用:"<<endl;
        for(int i=1;i<=anumber;i++)
        {
            if(player[i].kind=5)
            {
                cout<<i<<"号工厂"<<endl;
            }
        }
    }
};
void typeofficename ()
{
    for(int i=0;i<=name.length()-1;i++)
    {
        cout<<name[i];
    }
}
void prepare()
{
    money=8000000;
}
garage a[1001];//暂时无效 
computer b[10000 ];
int main()
{
    cout<<"欢迎来到手机帝国"<<endl;
    Sleep(500);
    cout<<"好了,我们开始吧"<<endl;
    cout<<"先给公司取名吧(不包含空格)"<<endl;
    cin>>name;
    cout<<"注册成功,你的公司:";
    typeofficename(); 
    cout<<endl;
    Sleep(500);
    cout<<"先送给你一笔客观的创业金800万"<<endl;
    Sleep(500); 
    cout<<"先造芯片工厂"<<endl; 
    cout<<"芯片工厂初次建造需要20000元"<<endl;
    Sleep(1000);
    cout<<"系统已经自动帮您办理手续"<<endl;
    player[anumber].newgarage(1);
    cout<<"哦,对了我们这里一月是10秒钟,只不过在教程阶段暂停了一下"<<endl;
    cout<<"你随时都可以建造新工厂"<<endl;
    cout<<"按下1建就可以建造工厂"<<endl;
    Sleep (1000); 
    cout<<"再按下1-5就可以建造不同类型的工厂"<<endl;
    cout<<" 1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 "<<endl;
    Sleep(500);
    cout<<"好的,接下来你就可以创建第一台机器了"<<endl;
    cout<<"按下2来研发型号"<<endl;
    cout<<"可是你需要把所有种类的工厂买下来"<<endl;
    cout<<"哦,对了在回复中回复0就表示撤销"<<endl;
    cout<<"暂时再见"<<endl;
    while(money>= -1000)
    {
        cout<<the_wrold_ttiimmee.yyeeaarr<<"年"<<the_wrold_ttiimmee.mmoonntthh<<"月"<<endl;
        cout<<"钱"<<money<<endl;
        cin>>ci;
        if(ci==1)//建造工厂 
        {
            cout<<"执行建造工厂指令"<<endl;
            cout<<"1:芯片   2:硬盘   3:显卡   4:液晶屏幕   5:组装 "<<endl;
            cin>>ci; 
            player[anumber].newgarage(ci);
        }
        if(ci==0)//撤销 
        {
            cout<<"正在执行撤销指令" <<endl;
        }
        if(ci==2)
        {
            if(newcomputer_001()==true)//newcomputer_001为判断电脑是否可以生产 
            {
                b[bnumber].newcomputer();
            }
            else cout<<"您还有一些原材料的工厂未获得所以无法生产电脑"<<endl;
        }
        Sleep(10000);
        the_wrold_ttiimmee.ttiimmeeup();
    }
}
bool newcomputer_001()
{
    if(yrxp==0||yryp==0||yrxk==0||yryjpm==0)
    {
        return false;
    }
    return true;
}

前面的是先声明后赋值,后面的写法是初始化;对于一般变量来说两种写法都没有太大的区别,初始化的编译速度快一点;主要区别体现在静态变量上,如果是

int  demo(){
  static int a = 0;
  static int b;
  b = 0;
  a++;
  b++;
  print("a的值为%d\n",a);
  print("b的值为%d\n",b);
}
```c
调用一次demo函数,a和b值一样;但是调用多次demo函数的话,a的值的递增,但是b的值不会变依然是1


```

69 70.结构里里定义的时候不能赋值 把year=0;删掉或者改成int year=0;就行了
85.声明一个对象需要在函数里声明,你这就像是全局变量一样声明是不行的。你可以这样

struct time
{
    int year=0;
    int month = 1;
    void timeup()
    {
        if(month==12)
        {
            year++;
            month=1;
        } 
        else month++;
    }
}the_wrold_time;   //放在这里一样可以达到你想要的效果