跳到正文

剪贴板

剪贴板 jgze2nx7

原文
剪贴板信息

剪贴板信息

收录
更新
C++
#include<bits/stdc++.h>
#include<conio.h>
#define gch Operator=getch()
#define rand(a,b) (1ll*rand()*rand()*rand()%(abs(a-b)+1)+min(a,b))
#define clean system("cls")
#define get(c) (Operator==c||Operator==c-32)
using namespace std;
int MaxFloat=20;
int MaxMax=1e9;
int FloatPoint=0;
int MinNumber=0;
int MaxNumber=100;
int *Point=&MaxNumber;
int *Max=&MaxMax;
int Number=0;
string EndFloat="";
string tips="Changing MAXNUMBER";
char Operator;
string random(int x){
	string str="";
	while(x--) str+=char(rand(48,57));
	return str;
}
void help(){
	clean;
	puts("Press C to reset");
	puts("Press J to change MAXNUMBER");
	puts("Press K to change MINNUMBER");
	puts("Press L to change FLOATPOINT");
	puts("Press 0 ~ 9 to input numbers");
	puts("Press E to exit");
	puts("Press G to generate the random number");
	while(gch,!get('e'));
}
void print(){
	clean;
	puts("Press H for help");
	puts("RNG by 957618");
	printf("\n\n          The random number:%9d",Number);
	cout<<EndFloat<<"\n\n";
	printf("MAXNUMBER:%9d  ",MaxNumber);
	printf("MINNUMBER:%9d  ",MinNumber);
	printf("FLOATPOINT:%9d\n",FloatPoint);
	cout<<tips<<'\n';
	puts("Press E to exit");
}
void operate(){
	if(Operator>47&&Operator<58){
		*Point=min(*Max,(*Point)*10+Operator-48);
		if(MaxNumber<MinNumber) MinNumber=MaxNumber;
	}
	if(get('c')) *Point=0;
	if(get('j')){
		Point=&MaxNumber;
		Max=&MaxMax;
		tips="Changing MAXNUMBER";
	}
	if(get('k')){
		Point=&MinNumber;
		Max=&MaxNumber;
		tips="Changing MINNUMBER";
	}
	if(get('l')){
		Point=&FloatPoint;
		Max=&MaxFloat;
		tips="Changing FLOATPOINT";
	}
	if(get('h')){
		help();
      return;
	}
	if(get('e')){
		clean;
		printf("THANKS FOR YOUR USING");
		exit(0);
	}
	if(get('g')){
		Number=rand((FloatPoint?MaxNumber-1:MaxNumber),MinNumber);
		EndFloat=FloatPoint?"."+random(FloatPoint):"";
	}
	if(get('b')){
		*Point/=10;
	}
	print();
}
int main(){
	srand(time(NULL));
	print();
	while(1){
		gch;
		operate();
	}
}