|
#include <stdio.h>
|
|
#include <windows.h>
|
|
#include <time.h>
|
|
struct myClock
|
|
{
|
|
int hour;
|
|
int minu;
|
|
int sec;
|
|
};
|
|
struct Goverment{
|
|
int HumanRes;
|
|
int MineRes;
|
|
int WoodRes;
|
|
int Gold;
|
|
};
|
|
|
|
struct ResidentHouse{
|
|
int HumanRes;
|
|
int MineRes;
|
|
int WoodRes;
|
|
int Gold;
|
|
};
|
|
struct MineFactory{
|
|
int HumanRes;
|
|
int MineRes;
|
|
int WoodRes;
|
|
int Gold;
|
|
};
|
|
struct WoodFactory{
|
|
int HumanRes;
|
|
int MineRes;
|
|
int WoodRes;
|
|
int Gold;
|
|
};
|
|
|
|
int count = -1;
|
|
int pastTime = 0;
|
|
void show(struct myClock *c)
|
|
{
|
|
system("cls");
|
|
|
|
printf("%02d:%02d:%02d \n", c->hour, c->minu, c->sec);
|
|
}
|
|
|
|
void tick(struct myClock *c)
|
|
{
|
|
if (++c->sec > 59)
|
|
{
|
|
c->sec = 0;
|
|
++c->minu;
|
|
}
|
|
|
|
if (c->minu > 59)
|
|
{
|
|
c->minu = 0;
|
|
++c->hour;
|
|
}
|
|
|
|
if (c->hour > 23)
|
|
c->hour = 0;
|
|
}
|
|
|
|
void run(struct myClock *c, struct Goverment* G, struct ResidentHouse* RH, struct MineFactory* MF, struct WoodFactory* WF)
|
|
{
|
|
|
|
while (1)
|
|
{
|
|
show(c);
|
|
tick(c);
|
|
++count;
|
|
printf("%d\n", count);
|
|
if (count == 5)
|
|
{
|
|
int probability;
|
|
count = 0;
|
|
//????????????һ??????????Դ
|
|
G->Gold++;
|
|
RH->HumanRes = RH->HumanRes + 12;
|
|
MF->MineRes = MF->MineRes + 5;
|
|
WF->WoodRes = WF->WoodRes + 10;
|
|
srand(c->sec);
|
|
//??????????????????????֮һ?ĸ??ʲ??????
|
|
probability = rand() % 3;
|
|
if (probability == 0 )
|
|
{
|
|
RH->Gold++;
|
|
MF->Gold++;
|
|
WF->Gold++;
|
|
printf("?????????+1?????+1??ľ?????+1\n");
|
|
}
|
|
|
|
printf("??ȥһ???ӣ?\n");
|
|
printf("???????????+1??????????????Դ+10???????Դ+5??ľ??ľ????Դ+10\n\n");
|
|
}
|
|
printf("????????????Դ??%d?? ?????Դ??%d?? ľ????Դ??%d?? ??ң?%d \n",G->HumanRes,G->MineRes,G->WoodRes,G->Gold);
|
|
printf("??????????????Դ??%d?? ?????Դ??%d?? ľ????Դ??%d?? ??ң?%d \n", RH->HumanRes, RH->MineRes, RH->WoodRes, RH->Gold);
|
|
printf("????????Դ??%d?? ?????Դ??%d?? ľ????Դ??%d?? ??ң?%d \n", MF->HumanRes, MF->MineRes, MF->WoodRes, MF->Gold);
|
|
printf("ľ??????????Դ??%d?? ?????Դ??%d?? ľ????Դ??%d?? ??ң?%d \n", WF->HumanRes, WF->MineRes, WF->WoodRes, WF->Gold);
|
|
|
|
Sleep(1000);
|
|
}
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
struct myClock C = { 0, 0, 0 };
|
|
struct Goverment G = { 0, 0, 0, 0 };
|
|
struct ResidentHouse RH = { 0, 0, 0, 0 };
|
|
struct MineFactory MF= { 0, 0, 0, 0 };
|
|
struct WoodFactory WF = { 0, 0, 0, 0 };
|
|
run(&C,&G,&RH,&MF,&WF);
|
|
return 0;
|
|
}
|