关于灵异输出(求调
  • 板块灌水区
  • 楼主yzsy25071621
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/10/14 16:08
  • 上次更新2023/11/2 13:53:52
查看原帖
关于灵异输出(求调
948951
yzsy25071621楼主2023/10/14 16:08

自己做的小玩意,结果输出出事了
当widths>60,好像不随机力(悲
不过还怪好玩的嘞
代码:

#include <windows.h>
#include <cstdlib>
#include <cstdio>
#include <ctime>

using namespace std;

inline void MvSnows();
inline void moveSnow(int);
inline void print();
inline void createRands();
inline void giveTopSnow();

int pct;
const int waitTime=0,heights=24,widths=56;
bool snow[heights][widths]={};
int temps[widths]={};

int main()
{
	srand(static_cast<unsigned int>(time(0)));
	while(true)
	{
		createRands();
		giveTopSnow();
		print();
		Sleep(waitTime);
		system("cls");
		MvSnows();
	}
	return 0;
}

inline void moveSnow(int row)
{
	for(int i=heights-1; i>=1; i--)
	{
		snow[row][i]=snow[row][i-1];
	}
	return;
}

inline void print()
{
	for(int i=1; i<=heights-1; i++)
	{
		for(int j=1; j<=widths-1; j++)
		{
			printf("%c",(snow[j][i]? '*':' '));
		}
		printf("\n");
	}
	for(int i=1; i<=widths; i++)
	{
		printf("-");
	}
	return;
}

inline void createRands()
{
	for(int i=1; i<=widths-1; i++)
	{
		temps[i]=rand()%100;
	}
	return;
}

inline void giveTopSnow()
{
	pct=rand()%21;
	for(int i=1; i<=widths-1; i++)
	{
		if(temps[i]<=pct)
		{
			snow[i][1]=true;
		}
	}
	return;
}

inline void MvSnows()
{
	for(int i=1; i<=widths-1; i++)
	{
		moveSnow(i);
	}
	return;
}

略长见谅

2023/10/14 16:08
加载中...