玩具版本~~

#include <iostream>
using namespace std;
typedef struct version
{
    int firstClassVersion;
    int secoidClassVersion;
    int thirdClassVersion;
} Version;

Version operator++(Version &ver)
{
    if (ver.firstClassVersion > 99)
    {
        Version wrongVersion = Version{0, 0, 0};
        cout << "版本号用完了"<< endl;
        return wrongVersion;
    }
    Version tmp;
    if (ver.thirdClassVersion + 1 > 99)
    {
        ver.thirdClassVersion = ver.thirdClassVersion  - 99;
        ver.secoidClassVersion++;
        if (ver.secoidClassVersion > 99)
        {
            ver.secoidClassVersion = ver.secoidClassVersion - 99;
            ver.firstClassVersion++;
        }
    }
    else
    {
        ver.thirdClassVersion = ver.thirdClassVersion + 1;
    }
    tmp.firstClassVersion = ver.firstClassVersion;
    tmp.secoidClassVersion = ver.secoidClassVersion;
    tmp.thirdClassVersion = ver.thirdClassVersion;
    return tmp;
}
void  getStringVersion(Version& ver,string& strVer)
{
      strVer = "v:" + std::to_string(ver.firstClassVersion) +  "." +  std::to_string(ver.secoidClassVersion) +  "." +  std::to_string(ver.thirdClassVersion) ;
      cout << strVer << endl;
}

void printVersion(Version &ver,int num)
{
    cout << "ver[ " << ver.firstClassVersion << "." << ver.secoidClassVersion << "." << ver.thirdClassVersion << "]"<<",num = "<<num << endl;
}
int main()
{
    Version curVer = Version{3, 0, 0};
    string strVer;
    printVersion(curVer,0);
    for (int i = 1; i < 1000000; i++)
    {
        ++curVer;   
        if(curVer.firstClassVersion == 100&&curVer.secoidClassVersion == 1&& curVer.thirdClassVersion==0 )
        {
            cout << "版本号已经用尽,需检查"<<endl;
            exit(1);
        }
        //printVersion(curVer,i);
        getStringVersion(curVer,strVer);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值