跳到正文

休闲·娱乐

炒股模拟器-飞竹

fly_bamboo约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年1月2日
篇幅
约 3 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
bool IsKeyPressed(WORD key)
{
    return (GetAsyncKeyState(key) & 0x8000) != 0;
}
int sum=0,day=0;
struct node
{
	string name;
	int w,cnt;
}s;
vector<node> stock;
map<string,bool> vis;
string shop[100]={"","广场","奶茶","餐厅","西餐","快餐","蛋糕","衣物","美妆","电竞"};
string name[100]={"","斯","思","司","美","每","琪","卡","雷","特","达","西","茜","当","肯","得","基","麦","劳","塔","汀","畹","町","加","佳","乐","茶","悦","喜","古","茗","都","咕","","","","","","","","",""};
signed main()
{
	srand(time(0));
	cout<<"欢迎来到炒股模拟器!"<<endl;
	sum=rand()%10000+1;
	while(sum<100) sum=rand()%10000+1;
	cout<<"你的初始资金为"<<sum<<" rmb"<<endl;
	while(1)
	{
		day++;
		cout<<"第"<<day<<"天!"<<endl;
		int num=rand()%50+1;
		for(int i=1;i<=num;i++)
		{
			string s="";
			int len=rand()%4+1;
			while(len<2) len=rand()%4+1;
			for(int j=1;j<=len;j++)
			{
				int x=rand()%32+1;
				s+=name[x];
			}
			int sh=rand()%9+1;
			s+=shop[sh];
			if(vis[s]==true) continue;
			vis[s]=true;
			int num;
			num=rand()%10000+1;
			if(s=="肯德基快餐"||s=="麦当劳快餐"||s=="塔斯汀快餐") num=5000;
			if(s=="茶颜悦色奶茶"||s=="古茗奶茶"||s=="都可奶茶") num=6000;
			stock.push_back({s,num});
			cout<<s<<" "<<num<<endl;
		}
		char c;
		cout<<"买股票(b)/卖股票(o)/下一天(n)";
		while(c=getch())
		{
			if(c=='n') break;
			if(c=='b')
			{

			}
		}
	}
	return 0;
}
原文